Skip to content

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.

    Transports

  • Middleware

    Everything in the processing pipeline is middleware, including KnightBus' own error handling and dead-lettering. Add your own.

    Middleware pipeline

  • Attachments

    Attach arbitrarily large files to messages without hitting transport size limits. Transport independent.

    Attachments

  • Singleton processing

    Guarantee that only one message is processed at a time across every running instance, using a distributed lock.

    Singleton processing

  • Sagas

    Long-running, stateful workflows with optimistic concurrency and pluggable state stores.

    Sagas

  • Throttling and concurrency

    Tune concurrency, prefetching and lock timeouts per message type, and throttle the host as a whole.

    Message processors

  • Scheduling

    Cron-triggered recurring jobs, plus deferred message delivery on the transports that support it.

    Scheduling

  • Observability

    OpenTelemetry, Application Insights and New Relic integrations, distributed trace propagation and a TCP liveness probe.

    Monitoring

Where to start

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.