Joselct.Communication.RabbitMQ 1.0.8

dotnet add package Joselct.Communication.RabbitMQ --version 1.0.8
                    
NuGet\Install-Package Joselct.Communication.RabbitMQ -Version 1.0.8
                    
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="Joselct.Communication.RabbitMQ" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Joselct.Communication.RabbitMQ" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Joselct.Communication.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 Joselct.Communication.RabbitMQ --version 1.0.8
                    
#r "nuget: Joselct.Communication.RabbitMQ, 1.0.8"
                    
#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 Joselct.Communication.RabbitMQ@1.0.8
                    
#: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=Joselct.Communication.RabbitMQ&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Joselct.Communication.RabbitMQ&version=1.0.8
                    
Install as a Cake Tool

Joselct.Communication.RabbitMQ

RabbitMQ transport implementation for Joselct.Communication.Contracts.
Supports .NET publishers and consumers with OpenTelemetry tracing, metrics, and dead letter queue handling.

Quick start

1. Register in Program.cs

builder.Services.AddRabbitMq(builder.Configuration);

// Register one consumer per queue
builder.Services.AddRabbitMqConsumer<OrderCreatedMessage, OrderCreatedHandler>(
    queueName: "orders.created",
    exchangeName: "orders-exchange",
    declareQueue: true);

// OpenTelemetry (optional)
builder.Services.AddOpenTelemetry()
    .AddRabbitMqInstrumentation();

2. Publish a message

public class OrderService(IExternalPublisher publisher)
{
    public async Task CreateOrderAsync(Order order, CancellationToken ct)
    {
        // ... business logic ...

        await publisher.PublishAsync(new OrderCreatedMessage
        {
            OrderId = order.Id,
            Source = "orders-service"
        }, ct: ct);
    }
}

3. Handle a message

public class OrderCreatedHandler : IIntegrationMessageConsumer<OrderCreatedMessage>
{
    public async Task HandleAsync(OrderCreatedMessage message, CancellationToken ct)
    {
        // Your business logic here
    }
}

Configuration (appsettings.json)

{
  "RabbitMQ": {
    "Host": "rabbitmq",
    "Port": 5672,
    "UserName": "guest",
    "Password": "guest",
    "VirtualHost": "/",
    "UseSsl": false,
    "ReconnectDelaySeconds": 5,
    "MaxReconnectAttempts": 0,
    "MaxRetryCount": 3,
    "DeadLetterExchange": "dlx"
  }
}
Key Default Description
Host localhost RabbitMQ hostname
Port 5672 AMQP port (5671 for TLS)
UserName guest Username
Password guest Password
VirtualHost / Virtual host
UseSsl false Enable TLS
ReconnectDelaySeconds 5 Delay between reconnection attempts
MaxReconnectAttempts 0 0 = unlimited
MaxRetryCount 3 Max processing retries before DLQ
DeadLetterExchange null DLX name; if set, queues are bound to it

Retry & Dead Letter Queue

When a handler throws an unhandled exception:

  1. The message is requeued up to MaxRetryCount times.
  2. On the final failure, a BasicNack with requeue: false is sent.
  3. If the queue has x-dead-letter-exchange configured (set via DeadLetterExchange option), RabbitMQ automatically routes the message to the DLQ.

The retry count is read from the standard x-death header that RabbitMQ populates automatically — no custom header management is required.

Recommended RabbitMQ setup:

Exchange: dlx   (type: direct or fanout, durable: true)
Queue:    dlq   (bound to dlx)

Interoperability

Tracing headers (traceparent, tracestate) are injected and read as plain strings (W3C TraceContext standard). This ensures compatibility with consumers in Python, Go, Java, and other languages without any additional decoding.

The consumer also falls back to reading byte[] headers for backwards compatibility with older publisher versions.

Metrics (OpenTelemetry)

Metric Description
rabbitmq.messages.published Successfully published messages
rabbitmq.messages.publish_failed Failed publish attempts
rabbitmq.messages.bytes_published Total bytes published
rabbitmq.messages.received Successfully processed messages
rabbitmq.messages.consume_failed Failed processing attempts
rabbitmq.messages.dead_lettered Messages sent to DLQ
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
1.0.8 277 3/6/2026
1.0.7 109 3/6/2026
1.0.6 122 3/6/2026
1.0.5 153 3/4/2026
1.0.4 110 3/4/2026
1.0.3 122 3/1/2026
1.0.2 115 3/1/2026
1.0.1 116 3/1/2026
1.0.0 126 2/28/2026