AzureServiceBus.Interaction
2.1.1
See the version list below for details.
dotnet add package AzureServiceBus.Interaction --version 2.1.1
NuGet\Install-Package AzureServiceBus.Interaction -Version 2.1.1
<PackageReference Include="AzureServiceBus.Interaction" Version="2.1.1" />
<PackageVersion Include="AzureServiceBus.Interaction" Version="2.1.1" />
<PackageReference Include="AzureServiceBus.Interaction" />
paket add AzureServiceBus.Interaction --version 2.1.1
#r "nuget: AzureServiceBus.Interaction, 2.1.1"
#:package AzureServiceBus.Interaction@2.1.1
#addin nuget:?package=AzureServiceBus.Interaction&version=2.1.1
#tool nuget:?package=AzureServiceBus.Interaction&version=2.1.1
AzureServiceBus.Interaction
Librería liviana para facilitar la integración con Azure Service Bus (colas) en proyectos .NET. Permite enviar y recibir mensajes JSON de forma simple, soporta múltiples consumidores simultáneos, reintentos automáticos con Polly, y se registra fácilmente mediante IServiceCollection.
🚀 Características principales
- ✅ Envío de mensajes JSON serializados
- ✅ Consumo automático con
BackgroundService - ✅ Soporte para múltiples colas simultáneas
- ✅ Reintentos automáticos con Polly
- ✅ Configuración por código (sin dependencia de
appsettings.json) - ✅ Diseñado exclusivamente para microservicios backend
- 🔒 Dead-letter handling básico integrado
- 🧪 Preparado para publicación como paquete NuGet
📦 Instalación
Requisitos
Agregar la referencia a Polly (usado para reintentos):
dotnet add package Polly
Agregá la librería AzureServiceBus.Interaction como proyecto o paquete NuGet (próximamente).
🛠️ Registro en Program.cs
using AzureServiceBus.Interaction;
using AzureServiceBus.Interaction.Extensions;
using AzureServiceBus.Interaction.Sender;
var builder = WebApplication.CreateBuilder(args);
// Leer connection string (desde config o directo)
var connectionString = builder.Configuration.GetConnectionString("AzureServiceBus");
builder.Services.AddAzureServiceBusInteraction(options =>
{
options.ConnectionString = connectionString;
});
// Registrar un consumidor
builder.Services.AddAzureServiceBusConsumer<ClienteCreado, ClienteCreadoHandler>("clientes-queue");
var app = builder.Build();
app.Run();
📩 Enviar mensajes
public class ClienteCreado
{
public string Nombre { get; set; }
public string Email { get; set; }
}
public class ClienteService
{
private readonly IAzureServiceBusSender _sender;
public ClienteService(IAzureServiceBusSender sender)
{
_sender = sender;
}
public async Task CrearClienteAsync()
{
var cliente = new ClienteCreado { Nombre = "Juan", Email = "juan@mail.com" };
await _sender.SendMessageAsync("clientes-queue", cliente);
}
}
📥 Consumir mensajes
Implementá la interfaz IAzureMessageHandler<T>:
public class ClienteCreadoHandler : IAzureMessageHandler<ClienteCreado>
{
public Task HandleAsync(ClienteCreado message, CancellationToken cancellationToken)
{
Console.WriteLine($"Nuevo cliente creado: {message.Nombre}");
return Task.CompletedTask;
}
}
Registrá el handler y la cola en Program.cs:
builder.Services.AddScoped<IAzureMessageHandler<ClienteCreado>, ClienteCreadoHandler>();
builder.Services.AddAzureServiceBusConsumer<ClienteCreado, ClienteCreadoHandler>("clientes-queue");
⚙️ Estructura
IAzureServiceBusSender: servicio para enviar mensajesIAzureMessageHandler<T>: interfaz para manejar mensajes recibidosAzureQueueBackgroundProcessor<T>:BackgroundServiceque escucha colas- Reintentos automáticos configurados con Polly (3 intentos con backoff exponencial)
🗺️ Roadmap (próximas mejoras)
- Soporte para encabezados (
ApplicationProperties) - Publicación y programación de mensajes (scheduled delivery)
- Soporte para topics/subscriptions (opcional)
- Publicación oficial en NuGet.org
🧪 Testing y casos de uso
Pensado para microservicios backend:
- Worker Services
- APIs ASP.NET Core
- Microservicios desacoplados vía mensajería
Ideal para entornos con procesamiento asincrónico de eventos, orquestación y arquitectura basada en eventos.
✉️ Consultas, mejoras o feedback: abrí un issue o contactame.
| 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 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. |
-
net8.0
- Azure.Messaging.ServiceBus (>= 7.18.4)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.3)
- Polly (>= 8.5.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.