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
<PackageReference Include="Joselct.Communication.RabbitMQ" Version="1.0.8" />
<PackageVersion Include="Joselct.Communication.RabbitMQ" Version="1.0.8" />
<PackageReference Include="Joselct.Communication.RabbitMQ" />
paket add Joselct.Communication.RabbitMQ --version 1.0.8
#r "nuget: Joselct.Communication.RabbitMQ, 1.0.8"
#:package Joselct.Communication.RabbitMQ@1.0.8
#addin nuget:?package=Joselct.Communication.RabbitMQ&version=1.0.8
#tool nuget:?package=Joselct.Communication.RabbitMQ&version=1.0.8
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:
- The message is requeued up to
MaxRetryCounttimes. - On the final failure, a
BasicNackwithrequeue: falseis sent. - If the queue has
x-dead-letter-exchangeconfigured (set viaDeadLetterExchangeoption), 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 | Versions 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. |
-
net10.0
- Joselct.Communication.Contracts (>= 1.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- OpenTelemetry (>= 1.15.0)
- OpenTelemetry.Api (>= 1.15.0)
- OpenTelemetry.Extensions.Hosting (>= 1.15.0)
- RabbitMQ.Client (>= 7.2.0)
-
net8.0
- Joselct.Communication.Contracts (>= 1.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- OpenTelemetry (>= 1.15.0)
- OpenTelemetry.Api (>= 1.15.0)
- OpenTelemetry.Extensions.Hosting (>= 1.15.0)
- RabbitMQ.Client (>= 7.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.