Aj.RabbitMQ.Core
1.0.54
dotnet add package Aj.RabbitMQ.Core --version 1.0.54
NuGet\Install-Package Aj.RabbitMQ.Core -Version 1.0.54
<PackageReference Include="Aj.RabbitMQ.Core" Version="1.0.54" />
<PackageVersion Include="Aj.RabbitMQ.Core" Version="1.0.54" />
<PackageReference Include="Aj.RabbitMQ.Core" />
paket add Aj.RabbitMQ.Core --version 1.0.54
#r "nuget: Aj.RabbitMQ.Core, 1.0.54"
#:package Aj.RabbitMQ.Core@1.0.54
#addin nuget:?package=Aj.RabbitMQ.Core&version=1.0.54
#tool nuget:?package=Aj.RabbitMQ.Core&version=1.0.54
Aj.RabbitMQ.Core
🚀 Biblioteca .NET para abstração de mensageria no RabbitMQ, totalmente extensível, orientada a microsserviços e multi-tenant.
✨ Recursos
✅ Conexão centralizada (singleton)
✅ Configuração via IConfiguration e DataAnnotations
✅ Declaração de exchanges, filas, bindings padronizados
✅ Suporte a prefetch (QoS)
✅ Envelope de mensagens estruturado (MessageEnvelope)
✅ Retry e DLQ integrado (padrão de robustez)
✅ Helpers para exchanges direct, topic, fanout
✅ Extensões para injeção no IServiceCollection
📦 Instalação
no seu projeto:
dotnet add package Aj.RabbitMQ.Core
⚙️ Configuração
adicione ao seu appsettings.json:
"RabbitMQSettings": {
"HostName": "localhost",
"UserName": "admin",
"Password": "123456",
"VirtualHost": "/",
"Port": 5672,
"RoutingKey": "order.vtex"
}
OBS: A Propriedade "RoutingKey" so deve ser informada para definir em qual fila os consumers devem se conectar, caso o serviço seja um publisher manter como null e definir a routingkey no momento da publicação.
e registre no Program.cs:
builder.Services.AddRabbitMQServices(builder.Configuration);
🚀 Uso Básico
var connectionFactory = serviceProvider.GetRequiredService<RabbitMQConnectionFactory>();
var channel = await connectionFactory.GetChannelAsync();
Envelope worker vs Outbox worker
Aj.RabbitMQ.Core ships two consumer families:
Envelope worker (RabbitMQWorker<T>) |
Outbox worker (RabbitMQOutboxWorker<T>) |
|
|---|---|---|
| Message shape | MessageEnvelope<T> with metadata |
Flat JSON body (your DTO) |
| Serializer | Newtonsoft (MessageEnvelopeSerializer) |
System.Text.Json (camelCase) |
| Exchange topology | {type}.direct + optional .retry/DLQ |
Default exchange, named queue |
Retry on EnvelopeStatus.Retry |
Publish to retry queue | Requeue (default) or RetryQueue via RabbitConsumerBinding |
| Connection | RabbitMQConnectionFactory singleton |
Raw ConnectionFactory per worker |
Use envelope workers for legacy integrations that publish wrapped envelopes. Use outbox workers for messages published by the Outbox Poller (flat camelCase JSON on a named queue).
Outbox worker example
public sealed class OrderWorker : RabbitMQOutboxWorker<PayloadContent>
{
public OrderWorker(IConfiguration config)
: base(config, "order.integrations.abacos") { }
protected override Task<EnvelopeStatus> HandleMessageAsync(
PayloadContent message,
CancellationToken cancellationToken) => ...;
}
Configure queue binding explicitly when needed:
public sealed class CustomOrderWorker : RabbitMQOutboxWorker<PayloadContent>
{
public CustomOrderWorker(IConfiguration config)
: base(config, new RabbitConsumerBinding
{
QueueName = "order.integrations.abacos",
PrefetchCount = 5,
DeclareQueueOnStartup = true
}) { }
protected override Task<EnvelopeStatus> HandleMessageAsync(
PayloadContent message,
CancellationToken cancellationToken) => ...;
}
Outbox delayed retry (opt-in)
Legacy outbox workers keep immediate BasicNack(requeue: true). For catalog queue names with a {queue}.retry sister queue (TTL → dead-letter back to main), set RetryMode = RabbitRetryMode.RetryQueue on the binding. Declare topology from the Outbox Poller with EnsureRetryTopologyOnPublish or DeclareQueueOnStartup = true on the binding.
: base(config, new RabbitConsumerBinding
{
QueueName = "order.integrations.abacos",
RetryMode = RabbitRetryMode.RetryQueue,
DeclareQueueOnStartup = true
})
🟦 Retry + DLQ
por padrão, sugerimos:
- fila normal
- fila
.retrycomx-message-ttl - fila
.dlqpara mensagens definitivas - exchanges:
direct.orderdirect.retrydirect.dlq
📚 Exemplos avançados
declarar exchange
await _channel.ExchangeDeclareAsync(
exchange: "direct.order",
type: "direct",
durable: true,
autoDelete: false
);
declarar fila com TTL + DLQ
await _channel.QueueDeclareAsync(
queue: "order.billing.retry",
durable: true,
exclusive: false,
autoDelete: false,
arguments: new Dictionary<string, object>
{
{ "x-message-ttl", 300000 },
{ "x-dead-letter-exchange", "direct.order" },
{ "x-dead-letter-routing-key", "order.created" }
}
);
✅ Checklist de Qualidade
- Multi-tenant
- Extensível
- Segue princípios SOLID
- Fácil integração com MediatR e Polly
- Suporte ao plugin management do RabbitMQ
👨💻 Contribuições
Pull Requests são muito bem-vindos!
Basta abrir uma issue ou PR neste repositório.
📄 Licença
MIT
| 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
- Aj.DCache (>= 1.0.35)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.9)
- RabbitMQ.Client (>= 7.2.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Aj.RabbitMQ.Core:
| Package | Downloads |
|---|---|
|
Aj.Platform.Core
Biblioteca de Uso Geral para integrações com as API OmsAj |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.54 | 198 | 9/18/2026 |
| 1.0.53 | 183 | 9/9/2026 |
| 1.0.53-beta.1 | 90 | 8/26/2026 |
| 1.0.52 | 199 | 7/21/2026 |
| 1.0.51 | 1,321 | 6/24/2026 |
| 1.0.50 | 931 | 6/5/2026 |
| 1.0.49 | 743 | 4/24/2026 |
| 1.0.48 | 561 | 3/20/2026 |
| 1.0.47 | 132 | 3/20/2026 |
| 1.0.46 | 359 | 3/11/2026 |
| 1.0.45 | 431 | 2/21/2026 |
| 1.0.44 | 623 | 1/19/2026 |
| 1.0.43 | 162 | 1/16/2026 |
| 1.0.42 | 211 | 1/14/2026 |
| 1.0.41 | 158 | 1/14/2026 |
| 1.0.40 | 182 | 1/13/2026 |
| 1.0.39 | 208 | 1/2/2026 |
| 1.0.38 | 405 | 12/18/2025 |
| 1.0.37 | 522 | 11/25/2025 |
| 1.0.36 | 206 | 11/25/2025 |
Outbox delayed retry: RabbitRetryMode.RetryQueue, OutboxRetryTopology, optional poller retry queue declare. Legacy Requeue default unchanged.