Skip to content

Repository files navigation

LiteBus

LiteBus logo

Build and test status NuGet version .NET 10 MIT license

LiteBus provides command, query, and event mediation for .NET 10 applications using CQS and DDD. Durable modules add inbox, outbox, saga, storage, dispatch, ingress, hosting, and operational APIs without requiring unrelated broker or database SDKs.

LiteBus is open source under the MIT license, free for commercial use, and will remain free.

What LiteBus Includes

  • Separate command, query, and event contracts, mediators, handlers, and pipelines.
  • Handler priorities, filters, pre-handlers, post-handlers, and error handlers.
  • Durable inbox processing for commands and transactional outbox processing for events.
  • Saga state with correlation, tenancy, optimistic concurrency, and duplicate dispatch suppression.
  • Opt-in PostgreSQL, Entity Framework Core, in-memory, AMQP, Kafka, AWS SQS, and Azure Service Bus adapters.
  • Generic Host integration, health checks, diagnostics, management endpoints, and OpenTelemetry registration.

Quick Start

Install the command module for Microsoft dependency injection:

dotnet add package LiteBus.Commands.Extensions.Microsoft.DependencyInjection

Define a command and handler:

public sealed record CreateProductCommand(string Name, decimal Price) : ICommand<Guid>;

public sealed class CreateProductCommandHandler : ICommandHandler<CreateProductCommand, Guid>
{
    public Task<Guid> HandleAsync(
        CreateProductCommand command,
        CancellationToken cancellationToken)
    {
        return Task.FromResult(Guid.NewGuid());
    }
}

Register messaging and command handlers:

builder.Services.AddLiteBus(liteBus =>
{
    liteBus.AddMessaging(_ => { });
    liteBus.AddCommands(commands =>
        commands.RegisterFromAssembly(typeof(Program).Assembly));
});

Inject ICommandMediator and send the command:

var productId = await commandMediator.SendAsync(
    new CreateProductCommand("Widget", 9.99m),
    cancellationToken);

The Getting Started guide covers commands, queries, events, module registration, and handler discovery.

Durable Messaging

The inbox persists commands before execution. The outbox persists events before publication. Saga storage tracks correlated workflow state. Each axis selects its storage, dispatch, ingress, and processor modules explicitly.

Use in-memory adapters for tests. Use PostgreSQL or Entity Framework Core when message writes must participate in an application transaction. Broker integrations remain separate packages so applications install only the SDKs they use.

See Reliable Messaging, Transactional Messaging Writes, and Package Selection.

Documentation

Build and Test

dotnet restore LiteBus.slnx
dotnet build LiteBus.slnx --configuration Release --no-restore
dotnet test LiteBus.slnx --configuration Release --no-build
pwsh ./scripts/Test-Documentation.ps1

Docker is required for integration suites that exercise PostgreSQL, AMQP, Kafka, AWS SQS, and Azure Service Bus emulators.

Project Policy

About

Modular .NET messaging for commands, queries, events, durable inbox and outbox processing, sagas, and broker transports.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages