Flux.Messaging is a messaging framework for .NET designed for Clean Architecture, DDD, and distributed systems.
It provides a unified model for:
- Publish / Subscribe (fire-and-forget)
- Distributed Request / Response
- Strongly-typed handlers
- Pluggable transports (InMemory, AMQP, etc.)
Flux.Messaging does not try to hide messaging complexity — it structures it properly.
- Clear separation between Bus, Dispatcher, and Transport
- First-class support for distributed request-response
- Contract-first design
- DDD / CQRS / Event-Driven friendly
- No dependency on ASP.NET
- Ready for AMQP 1.0 (Qpid, Azure Service Bus, etc.)
- InMemory transport for testing and local development
| Package | Description |
|---|---|
Flux.Messaging.Abstractions |
Public contracts (Bus, Handlers, Envelope, Transport) |
Flux.Messaging.Core |
Core implementations |
Flux.Messaging.InMemory |
InMemory transport and dispatcher |
Flux.Messaging.Extensions.DependencyInjection |
Developer Experience (DX) |
- Fire-and-forget
- Multiple handlers supported
- No response expected
- Request / Response
- Exactly one handler
- Uses
CorrelationIdandReplyTo - Can cross process and service boundaries
dotnet add package Flux.Messagingservices.AddFluxMessaging()
.UseInMemory();public record ProductAdded(Guid ProductId);public sealed class ProductAddedHandler : IMessageHandler<ProductAdded>
{
public Task HandleAsync(ProductAdded message, CancellationToken ct = default)
{
Console.WriteLine($"Product added: {message.ProductId}");
return Task.CompletedTask;
}
}await messageBus.PublishAsync(new ProductAdded(productId));public sealed record ReserveStock(Guid ProductId, int Quantity)
: IRequest<ReserveStockResult>;public sealed record ReserveStockResult(bool Success);public sealed class ReserveStockHandler
: IRequestHandler<ReserveStock, ReserveStockResult>
{
public Task<ReserveStockResult> HandleAsync(
ReserveStock request,
CancellationToken ct = default)
{
return Task.FromResult(new ReserveStockResult(true));
}
}var result = await messageBus.SendAsync<ReserveStockResult>(
new ReserveStock(productId, 2));Application
└─ IMessageBus
├─ Send (Request)
└─ Publish (Event)
Infrastructure
├─ ITransport (AMQP, InMemory, etc.)
└─ IMessageDispatcher
- Bus: public API
- Dispatcher: resolves handlers
- Transport: delivers envelopes
The transport does not know handlers.
The dispatcher does not know the transport.
Flux.Messaging is .NET-first, but transport-agnostic.
Other languages can:
- Consume AMQP envelopes
- Deserialize the payload
- Reply using
ReplyToandCorrelationId
No framework dependency is required.
The solution includes behavior-focused tests:
- Concurrency
- Multiple handlers
- Fault tolerance
- Dispatch correctness
This project is licensed under the Apache License, Version 2.0.
See the LICENSE file for details.