AzureServiceBus.Interaction 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AzureServiceBus.Interaction --version 2.0.0
                    
NuGet\Install-Package AzureServiceBus.Interaction -Version 2.0.0
                    
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="AzureServiceBus.Interaction" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AzureServiceBus.Interaction" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AzureServiceBus.Interaction" />
                    
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 AzureServiceBus.Interaction --version 2.0.0
                    
#r "nuget: AzureServiceBus.Interaction, 2.0.0"
                    
#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 AzureServiceBus.Interaction@2.0.0
                    
#: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=AzureServiceBus.Interaction&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AzureServiceBus.Interaction&version=2.0.0
                    
Install as a Cake Tool

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 y se registra fácilmente con IServiceCollection.


🚀 Características principales

  • ✅ Envío de mensajes JSON serializados
  • ✅ Consumo automático con BackgroundService
  • ✅ Registro de múltiples colas simultáneas
  • ✅ Reintentos automáticos con Polly
  • ✅ Configuración por código (no depende de appsettings.json)
  • ✅ Pensado para microservicios backend
  • 🔒 Dead-letter handling básico integrado
  • 🧪 Preparado para convertirse en paquete NuGet

📦 Instalación

Agregá la referencia a tu solución:

bash dotnet add package Polly

🛠️ Registro en Program.cs

using AzureServiceBus.Interaction; using AzureServiceBus.Interaction.Processor; using AzureServiceBus.Interaction.Sender; using Azure.Messaging.ServiceBus;

var builder = WebApplication.CreateBuilder(args);

// Leer connection string (podés usar IConfiguration o directamente del código) var connectionString = builder.Configuration.GetConnectionString("AzureServiceBus");

builder.Services.AddAzureServiceBusInteraction(connectionString);

var app = builder.Build();

app.Run();

📩 Enviar mensajes

public class ClienteCreado { public string Nombre { get; set; } public string Email { get; set; } }

// Dentro de un controller, service, etc. private readonly IAzureServiceBusSender _sender;

public async Task CrearCliente() { var cliente = new ClienteCreado { Nombre = "Juan", Email = "juan@mail.com" }; await _sender.SendMessageAsync("clientes-queue", cliente); }

📥 Consumir mensajes

public class ClienteCreadoHandler : IAzureMessageHandler<ClienteCreado> { public Task HandleAsync(ClienteCreado message, CancellationToken cancellationToken) { Console.WriteLine($"Nuevo cliente: {message.Nombre}"); return Task.CompletedTask; } }

Registro de handlers

Agregá tu handler como servicio:

builder.Services.AddScoped<IAzureMessageHandler<ClienteCreado>, ClienteCreadoHandler>();

Y registrá la cola a escuchar:

builder.Services.AddAzureServiceBusConsumer<ClienteCreado>("clientes-queue");

⚙️ Estructura IAzureServiceBusSender: servicio para enviar mensajes

AzureServiceBusBackgroundProcessor: BackgroundService que escucha una o más colas

IAzureMessageHandler<T>: interfaz para implementar handlers de mensajes

Reintentos configurados con Polly (x3 intentos con backoff exponencial)

🧭 Roadmap (próximas mejoras) Soporte para encabezados (ApplicationProperties)

Programación de mensajes (Scheduled)

Soporte opcional de topics/subscriptions

Publicación del paquete en NuGet.org

🧪 Testing La librería está diseñada para ser usada en microservicios backend con inyección de dependencias. Se recomienda usarla en proyectos como:

Worker Services

ASP.NET Core APIs

Microservicios desacoplados vía mensajería

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.