CommonHelpers.RabbitMQ
0.0.1-beta.1
This is a prerelease version of CommonHelpers.RabbitMQ.
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package CommonHelpers.RabbitMQ --version 0.0.1-beta.1
NuGet\Install-Package CommonHelpers.RabbitMQ -Version 0.0.1-beta.1
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="CommonHelpers.RabbitMQ" Version="0.0.1-beta.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CommonHelpers.RabbitMQ" Version="0.0.1-beta.1" />
<PackageReference Include="CommonHelpers.RabbitMQ" />
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 CommonHelpers.RabbitMQ --version 0.0.1-beta.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CommonHelpers.RabbitMQ, 0.0.1-beta.1"
#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 CommonHelpers.RabbitMQ@0.0.1-beta.1
#: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=CommonHelpers.RabbitMQ&version=0.0.1-beta.1&prerelease
#tool nuget:?package=CommonHelpers.RabbitMQ&version=0.0.1-beta.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
🐰 CommonHelpers.RabbitMQ
Adaptador resiliente de mensageria para RabbitMQ implementando a abstração unificada
IEventProducereIEventHandler<T>, com suporte automático a Publisher Confirms, Dead-Letter Queue (.dlq), retentativas com Polly e injeção de dependência simplificada para .NET 6, .NET 8 e .NET 9.
📦 Instalação
Adicione o pacote ao seu projeto via .NET CLI:
dotnet add package CommonHelpers.RabbitMQ --version 0.0.1-beta.1
🚀 Como Usar
1. Configuração no Program.cs
using CommonHelpers.RabbitMQ.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Registra a infraestrutura do RabbitMQ e o IEventProducer agnóstico
builder.Services.AddRabbitMqMessaging(builder.Configuration);
// Registra o consumidor de eventos para um handler específico
builder.Services.AddRabbitMqConsumer<OrderCreatedEvent, OrderCreatedHandler>(
queueName: "app.orders.created",
routingKey: "orders.created");
var app = builder.Build();
app.Run();
2. Publicando Eventos de Forma Agnóstica (IEventProducer)
Sua camada de aplicação ou domínio depende apenas da interface agnóstica IEventProducer:
using CommonHelpers.Messaging;
public class OrderService
{
private readonly IEventProducer _producer;
public OrderService(IEventProducer producer)
{
_producer = producer;
}
public async Task CreateOrderAsync(OrderDto order, CancellationToken ct)
{
var orderEvent = new OrderCreatedEvent(order.Id, order.Total);
// Publica sem nenhum acoplamento com o RabbitMQ!
await _producer.PublishAsync(orderEvent, cancellationToken: ct);
}
}
3. Consumindo Eventos (IEventHandler<T>)
using CommonHelpers.Messaging;
using CommonHelpers.RequestResponse;
public class OrderCreatedHandler : IEventHandler<OrderCreatedEvent>
{
public async Task<Result> HandleAsync(EventMessage<OrderCreatedEvent> message, CancellationToken ct)
{
Console.WriteLine($"Processando pedido {message.Payload.OrderId}, CorrelationId: {message.CorrelationId}");
// Retornar Result.Success() envia ACK para o RabbitMQ
// Retornar Result.Failure(...) direciona para a Dead-Letter Queue (.dlq)
return Result.Success();
}
}
4. Configuração no appsettings.json
{
"RabbitMq": {
"HostName": "localhost",
"Port": 5672,
"UserName": "guest",
"Password": "guest",
"VirtualHost": "/",
"ExchangeName": "amq.topic",
"ExchangeType": "topic",
"RetryCount": 3,
"PrefetchCount": 10
}
}
🏛️ Topologia Automática de Filas e DLQ
Ao registrar um consumidor com AddRabbitMqConsumer:
- A exchange principal (
ExchangeName) é declarada automaticamente. - A exchange de Dead-Letter (
ExchangeName.dlx) e a fila.dlqsão declaradas e vinculadas. - A fila principal é criada com argumentos
x-dead-letter-exchangeapontando para a.dlx. Em caso de erro fatal ou retentativas esgotadas, a mensagem vai automaticamente para a.dlq.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 is compatible. 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 was computed. 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.
-
net6.0
- CommonHelpers.RequestResponse (>= 0.0.1-beta.1)
- 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)
- Polly (>= 8.3.0)
- RabbitMQ.Client (>= 6.8.1)
-
net8.0
- CommonHelpers.RequestResponse (>= 0.0.1-beta.1)
- 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)
- Polly (>= 8.3.0)
- RabbitMQ.Client (>= 6.8.1)
-
net9.0
- CommonHelpers.RequestResponse (>= 0.0.1-beta.1)
- 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)
- Polly (>= 8.3.0)
- RabbitMQ.Client (>= 6.8.1)
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 |
|---|