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

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 .retry com x-message-ttl
  • fila .dlq para mensagens definitivas
  • exchanges:
    • direct.order
    • direct.retry
    • direct.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 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 (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
Loading failed

Outbox delayed retry: RabbitRetryMode.RetryQueue, OutboxRetryTopology, optional poller retry queue declare. Legacy Requeue default unchanged.