KnightBus¶
A fast, lightweight and extensible messaging framework for .NET that supports multiple active message transports.
When building BookBeat we discovered there is no silver bullet messaging technology — each one has its own trade-offs in reliability, performance, latency, scalability, price and capability. KnightBus exists so that the transport is a property of the message, not of the application. A single host can listen to Azure Service Bus, PostgreSQL and Redis at the same time, and you pick the right one per message type.
// This message travels over Azure Service Bus...
public class OrderPlaced : IServiceBusEvent { }
// ...and this one over Redis, in the same host.
public class ThumbnailRequested : IRedisCommand { }
Features¶
-
Multiple transports
Azure Service Bus, Azure Storage Queues, PostgreSQL, Redis and NATS — all active simultaneously, chosen per message.
-
Middleware
Everything in the processing pipeline is middleware, including KnightBus' own error handling and dead-lettering. Add your own.
-
Attachments
Attach arbitrarily large files to messages without hitting transport size limits. Transport independent.
-
Singleton processing
Guarantee that only one message is processed at a time across every running instance, using a distributed lock.
-
Sagas
Long-running, stateful workflows with optimistic concurrency and pluggable state stores.
-
Throttling and concurrency
Tune concurrency, prefetching and lock timeouts per message type, and throttle the host as a whole.
-
Scheduling
Cron-triggered recurring jobs, plus deferred message delivery on the transports that support it.
-
Observability
OpenTelemetry, Application Insights and New Relic integrations, distributed trace propagation and a TCP liveness probe.
Where to start¶
- Getting started — install the packages and get a message flowing.
- Core concepts — messages, mappings, processors and the host.
- Marker interfaces reference — the single page listing every interface that changes KnightBus' behaviour, and where to put it.
Runnable samples for every transport live in
samples in the
repository. They are built by CI, so they always compile against the current API.
Requirements¶
KnightBus targets net9.0 and net10.0.
Licence and credits¶
KnightBus is released under the MIT licence, copyright © BookBeat.
Main author: Niklas Arbin, Systems Architect @ BookBeat.
With thanks to everyone who has contributed their time and intellect to KnightBus, including Tobias Johansson, Albin Carnstam, Viktor Hartenberger, Magnus Baneryd, Olov Siktröm, Simon Aunér, André Virdarson, Tobias Balzano, Peter Bergman and Björn Bylund — and the full list of contributors on GitHub.