![]() |
VOOZH | about |
dotnet add package PANiXiDA.Core.Infrastructure.Messaging.Wolverine --version 2.0.2
NuGet\Install-Package PANiXiDA.Core.Infrastructure.Messaging.Wolverine -Version 2.0.2
<PackageReference Include="PANiXiDA.Core.Infrastructure.Messaging.Wolverine" Version="2.0.2" />
<PackageVersion Include="PANiXiDA.Core.Infrastructure.Messaging.Wolverine" Version="2.0.2" />Directory.Packages.props
<PackageReference Include="PANiXiDA.Core.Infrastructure.Messaging.Wolverine" />Project file
paket add PANiXiDA.Core.Infrastructure.Messaging.Wolverine --version 2.0.2
#r "nuget: PANiXiDA.Core.Infrastructure.Messaging.Wolverine, 2.0.2"
#:package PANiXiDA.Core.Infrastructure.Messaging.Wolverine@2.0.2
#addin nuget:?package=PANiXiDA.Core.Infrastructure.Messaging.Wolverine&version=2.0.2Install as a Cake Addin
#tool nuget:?package=PANiXiDA.Core.Infrastructure.Messaging.Wolverine&version=2.0.2Install as a Cake Tool
PANiXiDA.Core.Infrastructure.Messaging.Wolverine is a .NET library that connects PANiXiDA.Core application messaging abstractions to WolverineFx.
It provides an in-process mediator, in-process domain event publishing by default, optional Kafka topic routing for selected event types, and durable inbox/outbox support backed by PostgreSQL.
👁 CI
👁 NuGet
👁 NuGet downloads
👁 Target Framework
IMediator implementation based on Wolverine in-process invocation.IEventBus implementation based on Wolverine EF Core outbox.TypeLoadMode.Auto.<ItemGroup>
<PackageReference Include="PANiXiDA.Core.Infrastructure.Messaging.Wolverine" Version="..." />
</ItemGroup>
using PANiXiDA.Core.Infrastructure.Messaging.Wolverine.DependencyInjection;
builder.Services.AddWolverineMediator<AppDbContext>();
builder.Host.UseWolverineMediator<AppDbContext>(
builder.Configuration.GetConnectionString("PostgreSqlConnectionString")!,
typeof(CreateUserHandler).Assembly);
AddWolverineMediator<TDbContext>() registers PANiXiDA IMediator, IEventBus, and the EF Core outbox dispatcher.
UseWolverineMediator<TDbContext>() configures Wolverine, PostgreSQL message storage, EF Core transactions, request middleware, FluentValidation validators from discovery assemblies, durable local queues, durable inbox, and durable outbox.
The package sets Wolverine's application assembly to the process entry assembly. This keeps generated handler code in the publishable application assembly when using Wolverine code generation commands such as dotnet run -- codegen write.
The package uses Wolverine TypeLoadMode.Auto and includes Wolverine runtime compilation support for handler code that has not been pre-generated.
Kafka is opt-in per event type. If no Kafka producer is registered for an event, publishing stays in-process.
Create typed option models in the consuming infrastructure project:
using PANiXiDA.Core.Infrastructure.Messaging.Wolverine.Options;
public sealed class MainKafkaBrokerOption : KafkaBrokerOption
{
}
public sealed class UserCreatedKafkaProducerOption : KafkaProducerOption
{
}
public sealed class UserCreatedKafkaConsumerOption : KafkaConsumerOption
{
}
Register brokers, producers, and consumers in the Wolverine mediator configuration:
using PANiXiDA.Core.Infrastructure.Messaging.Wolverine.DependencyInjection;
builder.Services.AddWolverineMediator<AppDbContext>();
builder.Host.UseWolverineMediator<AppDbContext>(
builder.Configuration.GetConnectionString("PostgreSqlConnectionString")!,
builder.Configuration,
options =>
{
options.AddKafkaBroker<MainKafkaBrokerOption>();
options.AddKafkaProducer<UserCreatedKafkaProducerOption, UserCreated>();
options.AddKafkaConsumer<UserCreatedKafkaConsumerOption, UserCreated>();
},
typeof(UserCreatedHandler).Assembly);
Configuration sections are resolved by option type name:
{
"ConnectionStrings": {
"PostgreSqlConnectionString": "Host=localhost;Port=5432;Database=app;Username=app;Password=app"
},
"MainKafkaBrokerOption": {
"BootstrapServers": "localhost:9092"
},
"UserCreatedKafkaProducerOption": {
"TopicName": "users.created"
},
"UserCreatedKafkaConsumerOption": {
"TopicName": "users.created",
"ConsumerGroupId": "users-service",
"AutoOffsetReset": "Earliest"
}
}
For named Kafka brokers, put the broker name into broker and topic options:
public sealed class ExternalKafkaBrokerOption : KafkaBrokerOption
{
}
public sealed class ExternalUserCreatedKafkaProducerOption : KafkaProducerOption
{
}
{
"ExternalKafkaBrokerOption": {
"BrokerName": "external",
"BootstrapServers": "external-kafka:9092"
},
"ExternalUserCreatedKafkaProducerOption": {
"BrokerName": "external",
"TopicName": "external.users.created"
}
}
options.AddKafkaBroker<ExternalKafkaBrokerOption>();
options.AddKafkaProducer<ExternalUserCreatedKafkaProducerOption, UserCreated>();
The package enrolls TDbContext in Wolverine PostgreSQL message storage. If the application keeps Wolverine envelope tables in EF Core migrations, map them in the DbContext model:
using Wolverine.EntityFrameworkCore;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.MapWolverineEnvelopeStorage("wolverine");
}
Commands and queries are invoked in-process through Wolverine and PANiXiDA request contracts.
Domain events are published through IEventBus. By default, Wolverine dispatches them to local handlers. When a Kafka producer is registered for the event type, the same event is also routed to the configured Kafka topic through durable outbox.
Kafka consumers use durable inbox and map incoming topic messages to the configured event type with DefaultIncomingMessage<TEvent>().
The default request behavior pipeline is:
before: ValidationBehavior
before: BeginTransactionBehavior
after: PublishDomainEventsBehavior
after: CommitTransactionBehavior
after: FlushOutgoingMessagesBehavior
finally: CleanupTransactionBehavior
Validators are discovered from the same assemblies passed to UseWolverineMediator<TDbContext>() for handler discovery.
Custom behaviors can be appended or inserted before or after any behavior in the same stage:
using PANiXiDA.Core.Application.Messaging.Mediator.Behaviors;
using PANiXiDA.Core.Infrastructure.Messaging.Wolverine.Behaviors;
builder.Host.UseWolverineMediator<AppDbContext>(
builder.Configuration.GetConnectionString("PostgreSqlConnectionString")!,
behaviors =>
{
behaviors.Before.InsertAfter(
typeof(AuthorizeRequestBehavior<,>),
typeof(ValidationBehavior<,>));
behaviors.After.InsertBefore(
typeof(AuditRequestResultBehavior<,>),
typeof(CommitTransactionBehavior<,>));
behaviors.Finally.InsertAfter(
typeof(ReleaseRequestLockBehavior<,>),
typeof(CleanupTransactionBehavior<,>));
},
typeof(CreateUserHandler).Assembly);
The same behavior configuration can be combined with Kafka topology registration:
builder.Host.UseWolverineMediator<AppDbContext>(
builder.Configuration.GetConnectionString("PostgreSqlConnectionString")!,
builder.Configuration,
kafka =>
{
kafka.AddKafkaBroker<MainKafkaBrokerOption>();
kafka.AddKafkaProducer<UserCreatedKafkaProducerOption, UserCreated>();
},
behaviors =>
{
behaviors.After.InsertBefore(
typeof(AuditRequestResultBehavior<,>),
typeof(FlushOutgoingMessagesBehavior<,>));
},
typeof(UserCreatedHandler).Assembly);
dotnet restore
dotnet format
dotnet build --configuration Release
dotnet test --configuration Release
This project is licensed under the Apache-2.0 license.
See the file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.