Fast. Minimal. Universal.
PulseBus is a lightweight, provider-agnostic messaging abstraction for .NET, designed to unify message publishing and consuming across multiple providers with a focus on Clean Architecture and High Performance.
- Unified API: Single interface to interact with RabbitMQ, SQS, Kafka, etc.
- Middleware Pipeline: Extensible pipeline similar to ASP.NET Core.
- Flexible Serialization: Support for JSON, Protobuf, MessagePack, and custom serializers.
- Resilience: Built-in retry policies and idempotency support.
- Lightweight: Zero external dependencies in the core (
PulseBuspackage). - Extensible: Easily add new providers through a plugin-based design.
Install the base package via NuGet:
dotnet add package PulseBusThen, add the provider you need:
| Provider | NuGet Package |
|---|---|
| RabbitMQ | dotnet add package PulseBus.RabbitMQ |
| AWS SQS | dotnet add package PulseBus.SQS |
| Azure Queue | dotnet add package PulseBus.AzureQueue |
| Kafka | dotnet add package PulseBus.Kafka |
Register PulseBus in your dependency injection container (Program.cs or Startup.cs):
using PulseBus.Extensions;
services.AddPulseBus(builder =>
{
// Configure your provider
builder.UseRabbitMq(options =>
{
config.Host = "localhost";
config.Port = 5672;
config.Username = "guest";
config.Password = "guest";
config.UseTls = false;
});
});Send messages asynchronously to any configured bus:
// Previously in constructor
private readonly IMessageBus _messageBus;
public UserService(IMessageBus messageBus)
{
_messageBus = messageBus;
}
await _messageBus.PublishAsync("user.requested", new UserRequested
{
Email = "andres@example.com",
Name = "Andrés"
});Define message handlers easily:
[Queue("user.requested")]
[Retry(3, 5)]
[Prefetch(16)]
public class OrderCreatedListener
{
public Task HandleAsync(UserRequested message, IMessageContext context)
{
Console.WriteLine($"Processing {message.Email}");
return Task.CompletedTask;
}
}You can agree middlewares:
bus.UseMiddleware(new LoggingMiddleware());
bus.UseMiddleware(new RetryMiddleware());Implementation
public class LoggingMiddleware : IMessageMiddleware
{
public async Task InvokeAsync(MiddlewareContext context, MiddlewareDelegate next)
{
Console.WriteLine($"Processing ... {context.Envelope.MessageId}");
await next(context);
}
}PulseBus is built on solid interfaces that allow you to decouple your business logic from the messaging infrastructure:
IMessageBus: Main entry point.IMessageProducer/IMessageConsumer: Transport abstractions.IMessageMiddleware: For logging, validation, or telemetry.IIdempotencyStore: Integrated duplicate control.
This project is developed and maintained by Andrés Mariño. If you find this library useful, consider supporting its continued development:
This project is licensed under the MIT License. See the LICENSE file for details.
Made with ❤️ for the .NET community