RepletoryLib.Messaging.RabbitMQ
1.0.0
dotnet add package RepletoryLib.Messaging.RabbitMQ --version 1.0.0
NuGet\Install-Package RepletoryLib.Messaging.RabbitMQ -Version 1.0.0
<PackageReference Include="RepletoryLib.Messaging.RabbitMQ" Version="1.0.0" />
<PackageVersion Include="RepletoryLib.Messaging.RabbitMQ" Version="1.0.0" />
<PackageReference Include="RepletoryLib.Messaging.RabbitMQ" />
paket add RepletoryLib.Messaging.RabbitMQ --version 1.0.0
#r "nuget: RepletoryLib.Messaging.RabbitMQ, 1.0.0"
#:package RepletoryLib.Messaging.RabbitMQ@1.0.0
#addin nuget:?package=RepletoryLib.Messaging.RabbitMQ&version=1.0.0
#tool nuget:?package=RepletoryLib.Messaging.RabbitMQ&version=1.0.0
RepletoryLib.Messaging.RabbitMQ
MassTransit-based RabbitMQ implementation of IMessagePublisher and IEventBus.
Part of the RepletoryLib ecosystem -- standalone, reusable .NET 10 libraries with zero business logic.
Overview
RepletoryLib.Messaging.RabbitMQ provides a production-ready implementation of IMessagePublisher and IEventBus from RepletoryLib.Messaging.Abstractions using MassTransit with RabbitMQ transport. It supports consumer registration, dead letter queues, configurable concurrency, and retry policies.
Key Features
- MassTransit integration -- Built on MassTransit for robust messaging patterns
- Consumer registration -- Register message consumers via the configuration callback
- Dead letter queues -- Automatic DLQ for failed messages
- Configurable concurrency -- Prefetch count and concurrent message limits
- Retry policies -- Built-in retry with configurable count and interval
Installation
dotnet add package RepletoryLib.Messaging.RabbitMQ
Dependencies
| Package | Type |
|---|---|
RepletoryLib.Messaging.Abstractions |
RepletoryLib |
MassTransit.RabbitMQ |
NuGet (8.3.6) |
Prerequisites
- RabbitMQ 3+ with management plugin
docker-compose up -d rabbitmq
Quick Start
using RepletoryLib.Messaging.RabbitMQ;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRepletoryRabbitMQ(builder.Configuration, cfg =>
{
cfg.AddConsumer<OrderCreatedConsumer>();
cfg.AddConsumer<PaymentProcessedConsumer>();
});
{
"Messaging": {
"RabbitMQ": {
"Host": "localhost",
"Port": 5672,
"VirtualHost": "/",
"Username": "repletory",
"Password": "Repletory@123!",
"RetryCount": 3,
"RetryIntervalSeconds": 5,
"PrefetchCount": 16,
"ConcurrentMessageLimit": 1,
"EnableDeadLetterQueue": true
}
}
}
Configuration
RabbitMqOptions
| Property | Type | Default | Description |
|---|---|---|---|
Host |
string |
"localhost" |
RabbitMQ server host |
Port |
int |
5672 |
AMQP port |
VirtualHost |
string |
"/" |
RabbitMQ virtual host |
Username |
string |
"guest" |
Authentication username |
Password |
string |
"guest" |
Authentication password |
RetryCount |
int |
3 |
Message retry attempts |
RetryIntervalSeconds |
int |
5 |
Delay between retries |
PrefetchCount |
int |
16 |
Messages to prefetch |
ConcurrentMessageLimit |
int |
1 |
Max concurrent message processing |
EnableDeadLetterQueue |
bool |
true |
Enable DLQ for failed messages |
Usage Examples
Publishing Events
using RepletoryLib.Messaging.Abstractions.Interfaces;
public class OrderService
{
private readonly IMessagePublisher _publisher;
public OrderService(IMessagePublisher publisher) => _publisher = publisher;
public async Task CreateOrderAsync(Order order)
{
await _repository.SaveAsync(order);
await _publisher.PublishAsync(new OrderCreatedEvent
{
OrderId = order.Id,
CustomerId = order.CustomerId,
Total = order.Total
});
}
}
Creating a Consumer
using RepletoryLib.Messaging.Abstractions.Interfaces;
using RepletoryLib.Messaging.Abstractions.Models;
public class OrderCreatedConsumer : IMessageConsumer<OrderCreatedEvent>
{
private readonly IEmailService _email;
public OrderCreatedConsumer(IEmailService email) => _email = email;
public async Task ConsumeAsync(ConsumeContext<OrderCreatedEvent> context,
CancellationToken cancellationToken = default)
{
await _email.SendOrderConfirmationAsync(context.Message.OrderId);
}
}
Using IEventBus for Commands
using RepletoryLib.Messaging.Abstractions.Interfaces;
// Send a command to a specific queue (point-to-point)
await _eventBus.SendAsync(new ProcessPaymentCommand
{
OrderId = orderId,
Amount = 500m
}, "queue:payment-processor");
Integration with Other RepletoryLib Packages
| Package | Relationship |
|---|---|
RepletoryLib.Messaging.Abstractions |
Implements IMessagePublisher, IEventBus |
RepletoryLib.Messaging.Outbox |
Reliable outbox pattern before publishing to RabbitMQ |
RepletoryLib.Testing |
MockMessagePublisher for unit testing |
RepletoryLib.HealthChecks |
RabbitMQ health check included |
Troubleshooting
| Issue | Solution |
|---|---|
| Connection refused | Ensure RabbitMQ is running and credentials are correct. Check Host, Port, Username, Password. |
| Consumer not receiving messages | Verify the consumer is registered in AddRepletoryRabbitMQ callback |
| Messages going to DLQ | Check consumer logs for exceptions. Messages fail after RetryCount attempts. |
| High memory on RabbitMQ | Reduce PrefetchCount or increase consumer ConcurrentMessageLimit |
License
This project is licensed under the MIT License.
Copyright (c) 2024-2026 Repletory.
For complete documentation, infrastructure setup, and configuration reference, see the RepletoryLib main repository.
| 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
- MassTransit (>= 8.3.6)
- MassTransit.RabbitMQ (>= 8.3.6)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- RepletoryLib.Messaging.Abstractions (>= 1.0.0)
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.0 | 77 | 3/2/2026 |