Messaging frameworks for .NET
A messaging framework sits between the application and the broker client from the previous noteBrokers and clients for .NETFive messaging services a .NET service can talk to, what each is for, and what a raw client leaves to you.Opens in a new tab. The application writes message classes and handlers, and the framework does the plumbing that a raw client leaves out.
What a framework adds
- Handlers and routing. A consumer class is registered with the container and the framework delivers the right message type to it.
- Topology. It declares the exchanges, queues, topics and subscriptions from the message and consumer types (see routing and topologyRouting and topologyHow a messaging system decides where each message goes: exchange types, subscription filters and partition keys.Opens in a new tab).
- Serialization. Messages are turned into bytes and back, with headers such as message id and correlation id filled in.
- Retries and error queues. A failed handler is retried with immediate, interval or exponential policies, then the message is moved aside. See retries and backoffRetries and backoffRun a failed message again after a growing, randomised delay, and stop after a limit.Opens in a new tab and dead-letter queuesDead-letter queuesWhere a message goes when it cannot be processed, so the rest of the traffic keeps moving.Opens in a new tab.
- Outbox and inbox. Messages are saved in the same database transaction as the data, and duplicates are filtered on the way in. See the outbox and the inboxOutbox and inboxWrite the event in the same transaction as the data, publish it from there, and deduplicate on the way in.Opens in a new tab.
- Sagas. Long-running workflows keep their state between messages. See sagasSagasA workflow made of local transactions, with an undo step for each one.Opens in a new tab.
The four compared
| Framework | Licence, currently | Brokers | Known for |
|---|---|---|---|
| MassTransit | Version 9 is commercial, with the source available, with a 100% discount for qualifying startups and non-profits. Version 8 remains open source. | RabbitMQ, Azure Service Bus, Amazon SQS/SNS, ActiveMQ, SQL, Kafka, Event Hubs, in-memory | Consumers, retries, Entity Framework outbox, state-machine sagas |
| NServiceBus | Commercial. Free for development, paid per logical endpoint in production. | Azure Service Bus, Azure Storage Queues, Amazon SQS/SNS, RabbitMQ, SQL Server | Sagas, recoverability, outbox, monitoring tools |
| Wolverine | MIT | RabbitMQ, Azure Service Bus, Amazon SQS, Kafka, NATS and more | In-process mediator and messaging in one, durable inbox and outbox, sagas |
| CAP | MIT | Kafka, RabbitMQ, Azure Service Bus, Amazon SQS, NATS, Redis Streams, Pulsar | An outbox over your own database, with attribute-based subscribers |
The catch
A framework is a dependency that shapes the whole codebase. Message types, handler signatures and the saga model are all its types, so moving to another framework later means rewriting them. Licences also change: MediatR (see the mediator noteMediator pattern in .NETCommands and notifications dispatched to handlers inside one application, with one place that knows who handles what.Opens in a new tab) and MassTransit each moved to a commercial licence for a new major version. Read the current licence before choosing, and pin the version that matches it. A framework also presents a common model over brokers that differ, so a feature that exists only in one broker can be hard to reach.
Where it fits
When several services use messaging and each would otherwise rewrite retries, serialization and an outbox, a framework is cheaper than a raw client. For one queue and one consumer, a raw client may be enough. The next note walks through one framework, MassTransit 8, from contract to outbox.
Sources
- MassTransit, Massient · accessed June 12, 2026
- NServiceBus overview, Particular Docs · accessed June 12, 2026
- NServiceBus licensing, Particular Software · accessed June 12, 2026
- What is Wolverine, Wolverine · accessed June 12, 2026
- CAP, dotnetcore (GitHub) · accessed June 12, 2026