Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.
Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.
SlimMessageBus is a lightweight, flexible, and extensible messaging framework for .NET, supporting multiple message brokers, including Kafka, RabbitMQ, Azure EventHubs, MQTT, Redis Pub/Sub, and more. It simplifies asynchronous communication and integrates seamlessly with modern .NET applications.
See how to migrate from MediatR or MassTransit
dotnet add package SlimMessageBus
# Add specific transport provider, e.g. Kafka
dotnet add package SlimMessageBus.Host.Kafka
# Add serialization plugin
dotnet add package SlimMessageBus.Host.Serialization.SystemTextJsonIMessageBus bus; // injected
public record OrderCreatedEvent(int OrderId);
await bus.Publish(new OrderCreatedEvent(123));public class OrderCreatedEventConsumer : IConsumer
{
public async Task OnHandle(OrderCreatedEvent message, CancellationToken cancellationToken)
{
// Handle the event
}
}public record CreateCustomerCommand(string Name) : IRequest;
public record CreateCustomerCommandResult(Guid CustomerId);
var result = await bus.Send(new CreateCustomerCommand("John Doe"));
public class CreateCustomerCommandHandler : IRequestHandler
{
public async Task OnHandle(CreateCustomerCommand request, CancellationToken cancellationToken)
{
// Create customer logic
return new(Guid.NewGuid());
}
}…The configuration can be modularized (for modular monoliths).
| Name | Description | NuGet |
|---|---|---|
SlimMessageBus |
The core API for SlimMessageBus | |
| Transports | ||
.Host.AmazonSQS |
Transport provider for Amazon SQS / SNS | |
.Host.AzureEventHub |
Transport provider for Azure Event Hubs | |
.Host.AzureServiceBus |
Transport provider for Azure Service Bus | |
.Host.GooglePubSub |
Transport provider for Google Cloud Pub/Sub | |
.Host.Kafka |
Transport provider for Apache Kafka | |
.Host.MQTT |
Transport provider for MQTT | |
.Host.Memory |
Transport provider implementation for in-process (in memory) message passing (no messaging infrastructure required) | |
.Host.NATS |
Transport provider for NATS | |
.Host.PostgreSql |
Transport provider implementation for PostgreSQL database message passing | |
.Host.RabbitMQ |
Transport provider for RabbitMQ | |
.Host.Redis |
Transport provider for Redis | |
.Host.Sql |
Transport provider implementation for SQL Server / Azure SQL database message passing | |
| Serialization | ||
.Host.Serialization.Json |
Serialization plugin for JSON (Newtonsoft.Json library) | |
.Host.Serialization.SystemTextJson |
Serialization plugin for JSON (System.Text.Json library) | |
.Host.Serialization.Avro |
Serialization plugin for Avro (Apache.Avro library) | |
.Host.Serialization.Hybrid |
Plugin that delegates serialization to other serializers based on message type | |
.Host.Serialization.GoogleProtobuf |
Serialization plugin for Google Protobuf | |
| Plugins | ||
.Host.AspNetCore |
Integration for ASP.NET Core | |
.Host.Interceptor |
Core interface for interceptors | |
.Host.FluentValidation |
Validation for messages based on FluentValidation | |
.Host.Outbox.PostgreSql |
Transactional Outbox using PostgreSQL | |
.Host.Outbox.PostgreSql.DbContext |
Transactional Outbox using PostgreSQL with EF DataContext integration | |
.Host.Outbox.Sql |
Transactional Outbox using MSSQL | |
.Host.Outbox.Sql.DbContext |
Transactional Outbox using MSSQL with EF DataContext integration | |
.Host.Outbox.MongoDb (beta) |
Transactional Outbox using MongoDB | |
.Host.AsyncApi |
AsyncAPI specification generation via Saunter | |
.Host.CircuitBreaker.HealthCheck |
Consumer circuit breaker based on health checks |
Typically the application layers (domain model, business logic) only need to depend on SlimMessageBus which is the facade, and ultimately the application hosting
No open issues yet, or sync has not completed.