Excalibur
Excalibur is a modular, high-performance .NET framework for building message-driven applications.
Start with Excalibur.Dispatch as a type-safe message dispatcher, then add domain modeling, event
sourcing, sagas, or compliance as your architecture requires — every package beyond the first is
optional, and they all share one Excalibur.* namespace, so adding one never means rewriting what
you already have.
The API is not frozen until RC, and some shipped behaviour does not yet match what this documentation describes. Read Known issues before you adopt Excalibur for anything you depend on.
Key features
Messaging and the pipeline:
- Message dispatching — send actions and events to handlers with full type safety, no reflection on the hot path
- Results and errors — railway-style success/failure without exceptions, mapped to the correct HTTP status by one call
- Pipeline and middleware — validation, logging, transactions, authorization and more as composable behaviours
- Transports — Kafka, RabbitMQ, Azure Service Bus, AWS SQS, Google Pub/Sub, Pulsar, MQTT, IBM MQ, gRPC, and in-memory
- Message context — correlation and causation IDs propagated automatically for distributed tracing
Domain and persistence:
- Domain modeling — aggregates, entities, value objects
- Event sourcing — event stores, snapshots, upcasting, replay
- CQRS and projections — read models built from the event stream
- Sagas and durable workflows — long-running, multi-step processes that survive restarts
- Data access — Dapper-based access across SQL Server, PostgreSQL, MySQL, Cosmos DB, DynamoDB, MongoDB, Spanner, Firestore, Redis, Elasticsearch and OpenSearch
Reliability and coordination:
- Outbox and inbox — reliable send and idempotent receive
- Change data capture — stream database changes as messages
- Background jobs — scheduled and recurring work
- Leader election — single-leader coordination across instances
- Caching — opt-in caching infrastructure
Security, compliance and operations:
- Authorization — fail-closed by default, speaking native
ASP.NET Core
[Authorize]andAuthorizationHandler - Audit logging — hash-chained, tamper-evident audit trails with SIEM export
- Compliance — GDPR, SOC 2 and FedRAMP support
- Multi-tenancy — tenant-scoped reads and writes
- Observability — OpenTelemetry traces, metrics and health checks
- Operations — diagnostics and the operations dashboard
Build and ship:
- Source generators — compile-time handler discovery, Native AOT friendly, no runtime reflection
- Testing — fixtures and conformance kits for your own handlers
- Deployment — ASP.NET Core, Azure Functions, AWS Lambda, Google Cloud Functions, Docker, Kubernetes and on-premises
That is the whole surface. All 194 packages are listed by category in the Package Matrix, including the metapackages that configure an entire provider in one line. For per-type and per-member detail, see the API reference.
Why choose Excalibur?
- Drop-in replacement for MediatR. The concepts map one-to-one, and the migration guide covers both a compatibility-shim route and a full port. Guides also exist for MassTransit and NServiceBus.
- Results reach the HTTP edge without boilerplate. A handler returns an
IMessageResult;.ToHttpResult()maps it to 403 for an authorization failure, 400 for validation,ProblemDetailsfor structured errors and 500 for the rest. You write that mapping once, not in every endpoint. - Low allocation on the hot path. 96 B allocated per command and roughly 60 ns of dispatch overhead, each measured on a dated, reproducible benchmark — see Performance for the method.
- Secure by default. Authorization denies when a decision is missing rather than falling open, and audit trails are hash-chained so tampering is detectable rather than merely discouraged.
- Modular, not monolithic. Install
Excalibur.Dispatchalone and nothing else comes with it. Every further capability is a separate package you opt into. - Built for AOT. Handler discovery is source-generated, so trimming and Native AOT work without runtime reflection.
Quick start
Two commands and one file. No database and no message broker — messages dispatch in-process by default, so nothing below needs infrastructure to run.
1. Install
dotnet add package Excalibur.Dispatch.Hosting.AspNetCore
Excalibur.Dispatch and Excalibur.Dispatch.Abstractions come in transitively. Building a console
app or worker with no HTTP edge? Install Excalibur.Dispatch on its own instead.
2. Write Program.cs
This is the entire application. Copy it as-is.
using Excalibur.Dispatch;
using Excalibur.Dispatch.Delivery;
using Excalibur.Dispatch.Hosting.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
// Auto-discovers handlers in this assembly.
// Handlers live in another project? Name it: AddDispatch(typeof(MyHandler).Assembly)
builder.Services.AddDispatch();
var app = builder.Build();
app.MapPost("/orders", async (CreateOrderRequest req, IDispatcher dispatcher, CancellationToken ct) =>
{
var result = await dispatcher.DispatchAsync(new CreateOrderAction(req.CustomerId, req.Items), ct);
// Maps the result to the correct status: 202 on success,
// 403 / 400 / ProblemDetails / 500 on failure. No hand-written mapping.
return result.ToHttpResult();
});
app.Run();
// --- The action, its handler, and the request body ---
public record CreateOrderAction(string CustomerId, List<string> Items) : IDispatchAction;
public record CreateOrderRequest(string CustomerId, List<string> Items);
public class CreateOrderHandler : IActionHandler<CreateOrderAction>
{
public Task HandleAsync(CreateOrderAction action, CancellationToken cancellationToken)
{
// Your business logic here.
return Task.CompletedTask;
}
}
3. Run it
dotnet run
curl -X POST http://localhost:5000/orders \
-H 'Content-Type: application/json' \
-d '{"customerId":"acme","items":["widget"]}'
That is the whole loop — an action, a handler, and a result mapped to the right HTTP status with one call. Everything else in Excalibur is optional and additive.
Next steps
| If you are… | Start here |
|---|---|
| New to Excalibur | Dispatch Only — the same file above, extended with a query, an event and middleware. Still one package, still no infrastructure. |
| Working through a tutorial | Getting Started, then the order system and event sourcing tutorials |
| Coming from another library | MediatR · MassTransit · NServiceBus |
| Deciding what to install | Pick Your Stack for a guided choice, Package Guide for the reasoning, Package Matrix for all 194 packages |
| Learning the fundamentals | Core Concepts — actions, handlers, results, context and configuration |
| Evaluating Excalibur | Performance, Architecture and Known issues |
| Looking for help | Support — how to get help, report a bug, or raise a security issue |