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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YAMCqrs.EventBus.Provider.RabbitMq" Version="10.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YAMCqrs.EventBus.Provider.RabbitMq" Version="10.0.3" />
                    
Directory.Packages.props
<PackageReference Include="YAMCqrs.EventBus.Provider.RabbitMq" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YAMCqrs.EventBus.Provider.RabbitMq --version 10.0.3
                    
#r "nuget: YAMCqrs.EventBus.Provider.RabbitMq, 10.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package YAMCqrs.EventBus.Provider.RabbitMq@10.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=YAMCqrs.EventBus.Provider.RabbitMq&version=10.0.3
                    
Install as a Cake Addin
#tool nuget:?package=YAMCqrs.EventBus.Provider.RabbitMq&version=10.0.3
                    
Install as a Cake Tool

YAMCqrs.EventBus.Provider.RabbitMq

Documentacion en espaΓ±ol

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

  • ConnectionString Connection string used to connect to Rabbit.

  • QueueGroupName Consumer 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.Client
  • YAMCqrs.EventBus.Core

πŸ“€ Publishing Events

To publish an event:

  1. Inherit from RabbitPublishEvent
  2. Define the Topic (also called exchange)
  3. Define the RoutingKey
  4. 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:

  1. Inherit from RabbitSubscribeEvent
  2. Define a constant topic (also called exchange)
  3. Define a constant RoutingKey
  4. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 174 6/21/2026