YAMCqrs.EventBus.Provider.RabbitMq
10.0.3
dotnet add package YAMCqrs.EventBus.Provider.RabbitMq --version 10.0.3
NuGet\Install-Package YAMCqrs.EventBus.Provider.RabbitMq -Version 10.0.3
<PackageReference Include="YAMCqrs.EventBus.Provider.RabbitMq" Version="10.0.3" />
<PackageVersion Include="YAMCqrs.EventBus.Provider.RabbitMq" Version="10.0.3" />
<PackageReference Include="YAMCqrs.EventBus.Provider.RabbitMq" />
paket add YAMCqrs.EventBus.Provider.RabbitMq --version 10.0.3
#r "nuget: YAMCqrs.EventBus.Provider.RabbitMq, 10.0.3"
#:package YAMCqrs.EventBus.Provider.RabbitMq@10.0.3
#addin nuget:?package=YAMCqrs.EventBus.Provider.RabbitMq&version=10.0.3
#tool nuget:?package=YAMCqrs.EventBus.Provider.RabbitMq&version=10.0.3
YAMCqrs.EventBus.Provider.RabbitMq
RabbitMq provider for the YAMCqrs.EventBus ecosystem.
This package adds support for publishing and consuming integration events using RabbitMq as the messaging broker.
The implementation integrates with YAMCqrs.EventBus.Core and uses a decoupled architecture based on persistence, asynchronous processing, and internal workers.
βοΈ Installation
dotnet add package YAMCqrs.EventBus.Provider.RabbitMq
π Quick Start
Register Rabbit in the dependency container:
builder.Services.AddEventBus(opt =>
{
// Base EventBus configuration
})
.UseRabbit(new YAMCqrs.EventBus.Provider.RabbitMq.Configuration.RabbitConfigurationOptions()
{
ConnectionString = "cs_Rabbit",
QueueGroupName = "TestApp",
});
Using "cs_Rabbit" as ConnectionString, the library will look up the real value in ConnectionStrings:Rabbit following ADR 13.
βοΈ Configuration
RabbitConfigurationOptions
ConnectionStringConnection string used to connect to Rabbit.QueueGroupNameConsumer group used for distributed consumption of topics.
π οΈ Main Features
Decoupled persistence
Messages are first persisted and then processed in independent scopes.
Benefits:
- resilience
- asynchronous processing
- infrastructure decoupling
- controlled retry
Safe consumption
Message fetching is content-agnostic.
If a message has an invalid format:
- the error occurs inside the application
- no infinite loop is created in Rabbit
- the offset can continue moving forward
This prevents permanently blocking the topic.
Automatic reconnection retries
Rabbit requires all topics to exist before starting the consumer.
If any topic does not exist:
- the connection will keep retrying indefinitely
- errors are logged
- the system recovers automatically when the topic appears
Source Generation
The library uses Source Generators to:
- discover topics automatically
- register consumers
- avoid Reflection
- improve startup performance
π Dependencies
RabbitMQ.ClientYAMCqrs.EventBus.Core
π€ Publishing Events
To publish an event:
- Inherit from
RabbitPublishEvent - Define the Topic (also called exchange)
- Define the RoutingKey
- Use
IEventPublisher
The actual publish happens in a separate scope. The handler only records the intent to publish.
π‘ Example Publish Event
internal sealed class MyRabbitPublishEvent : RabbitPublishEvent
{
public const string TopicName = "my.rabbit.event";
public const string RoutingKeyName = "my.route";
public override string RoutingKey => RoutingKeyName;
public override void AddCustomHeaders(ref Dictionary<string, string> headers)
{
return;
}
public override string Topic()
{
return TopicName;
}
}
π‘ Publishing the Event
internal sealed class MyLogicCommandHandler(
IEventPublisher eventPublisher)
: ICommandHandler<MyLogicCommand, string>
{
public async Task<Result<string>> HandleAsync(
MyLogicCommand command,
CancellationToken cancellationToken = default)
{
await eventPublisher.PublishAsync(
new MyRabbitPublishEvent(),
cancellationToken);
return Result<string>.Ok(command.Name);
}
}
π₯ Consuming Events
To consume events:
- Inherit from
RabbitSubscribeEvent - Define a constant topic (also called exchange)
- Define a constant RoutingKey
- Implement
ICommandHandler<TEvent, bool>
The topic name must be:
- a string literal
- or a constant
This is required so the Source Generator can automatically discover topics.
π‘ Example Subscribe Event
internal sealed class MyRabbitSubscribeEvent() : RabbitSubscribeEvent(MyRabbitPublishEvent.TopicName)
{
public override string RoutingKey => MyRabbitPublishEvent.RoutingKeyName;
public string RandomProduct { get; set; } = string.Empty;
}
π‘ Event Processing
internal sealed partial class MyRabbitSubscribeEventHanlder
: ICommandHandler<MyRabbitSubscribeEvent, bool>
{
public Task<Result<bool>> HandleAsync(
MyRabbitSubscribeEvent command,
CancellationToken cancellationToken = default)
{
return Task.FromResult(Result<bool>.Success(true));
}
}
β‘ Architectural Highlights
- Rabbit integration
- Event-driven architecture
- Domain Events
- Integration Events
- Outbox-like processing
- Asynchronous consumers
- Retry support
- Low coupling
- Source-generated discovery
- Reflection-free startup
- Distributed messaging
- Background processing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- RabbitMQ.Client (>= 7.2.1)
- YAMCqrs.EventBus.Core (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.3 | 175 | 6/21/2026 |