-
Notifications
You must be signed in to change notification settings - Fork 16
Dependency Graph
LiteBus is split into small packages so applications can reference only the modules they run. The graph has four layers: runtime, messaging, semantic modules, and optional infrastructure.
Runtime.Abstractions
-> Runtime
-> Runtime.Extensions.Microsoft.DependencyInjection
-> Runtime.Extensions.Autofac
Messaging.Abstractions
-> Messaging
-> Messaging.Extensions.Microsoft.DependencyInjection
-> Messaging.Extensions.Autofac
Commands.Abstractions -> Commands
Queries.Abstractions -> Queries
Events.Abstractions -> Events
Inbox.Abstractions -> Inbox -> Inbox.PostgreSql
Outbox.Abstractions -> Outbox -> Outbox.PostgreSql
Commands/Queries/Events/Inbox/Outbox depend on Messaging and Runtime.Abstractions.
Storage packages depend on their abstraction package and the external store client.
DI extension packages depend on the module package and the matching runtime adapter.
| Package | Role | Project dependencies | External dependencies |
|---|---|---|---|
LiteBus.Runtime.Abstractions |
DI-neutral service registration contracts | none | none |
LiteBus.Runtime |
Default module registry and dependency descriptor handling | Runtime.Abstractions |
none |
LiteBus.Runtime.Extensions.Microsoft.DependencyInjection |
Microsoft DI adapter | Runtime |
Microsoft.Extensions.DependencyInjection.Abstractions |
LiteBus.Runtime.Extensions.Autofac |
Autofac adapter | Runtime |
Autofac |
LiteBus.Messaging.Abstractions |
Handler contracts, mediation contracts, execution context, durable contract contracts | Runtime.Abstractions |
none |
LiteBus.Messaging |
Message registry, mediator, descriptor builders, default serializer, durable contract registry |
Messaging.Abstractions, Runtime.Abstractions
|
System.Text.Json from the BCL |
LiteBus.Commands.Abstractions |
Command contracts, command handlers, command mediation settings | Messaging.Abstractions |
none |
LiteBus.Commands |
Command mediator and command module |
Commands.Abstractions, Messaging, Runtime.Abstractions
|
none |
LiteBus.Queries.Abstractions |
Query contracts, stream query contracts, query handlers | Messaging.Abstractions |
none |
LiteBus.Queries |
Query mediator and query module |
Queries.Abstractions, Messaging, Runtime.Abstractions
|
none |
LiteBus.Events.Abstractions |
Event contracts, event handlers, event mediation settings | Messaging.Abstractions |
none |
LiteBus.Events |
Event mediator and event module |
Events.Abstractions, Messaging, Runtime.Abstractions
|
none |
LiteBus.Inbox.Abstractions |
Durable command scheduler contracts, envelopes, processor contracts, store roles |
Commands.Abstractions, Messaging.Abstractions
|
none |
LiteBus.Inbox |
Scheduler, inbox processor, inbox module |
Commands.Abstractions, Inbox.Abstractions, Messaging, Runtime.Abstractions
|
none |
LiteBus.Inbox.PostgreSql |
Raw Npgsql inbox store and schema helper | Inbox.Abstractions |
Npgsql |
LiteBus.Outbox.Abstractions |
Outbox writer contracts, envelopes, processor contracts, dispatcher contract, store roles | Messaging.Abstractions |
none |
LiteBus.Outbox |
Outbox writer, integration outbox, outbox processor, LiteBus event dispatcher, outbox module |
Events.Abstractions, Messaging, Outbox.Abstractions, Runtime.Abstractions
|
none |
LiteBus.Outbox.PostgreSql |
Raw Npgsql outbox store and schema helper | Outbox.Abstractions |
Npgsql |
LiteBus.*.Extensions.Microsoft.DependencyInjection |
Module registration adapters for Microsoft DI | Module package, Microsoft DI runtime adapter | Microsoft DI adapter dependency only |
LiteBus.*.Extensions.Autofac |
Module registration adapters for Autofac | Module package, Autofac runtime adapter | Autofac adapter dependency only |
LiteBus |
Aggregate package for core modules and durable modules | Commands, Queries, Events, Messaging, Inbox, Outbox, and abstractions | none beyond referenced packages |
Test-only packages live under tests/Directory.Packages.props.
| Package | Used for |
|---|---|
xunit, xunit.runner.visualstudio
|
Unit and integration test execution |
AwesomeAssertions |
Test assertions |
Microsoft.NET.Test.Sdk |
.NET test host |
coverlet.collector, coverlet.msbuild
|
Coverage collection |
Testcontainers.PostgreSql |
PostgreSQL integration tests |
Npgsql |
PostgreSQL integration tests |
BenchmarkDotNet |
Benchmark project package, declared by the benchmark project |
The PostgreSQL integration tests require Docker because Testcontainers starts postgres:16-alpine during the test run.
builder.Services.AddLiteBus(liteBus =>
{
liteBus.AddCommandModule(commands =>
{
commands.RegisterFromAssembly(typeof(Program).Assembly);
});
liteBus.AddQueryModule(queries =>
{
queries.RegisterFromAssembly(typeof(Program).Assembly);
});
liteBus.AddEventModule(events =>
{
events.RegisterFromAssembly(typeof(Program).Assembly);
});
});builder.Services.AddLiteBus(liteBus =>
{
liteBus.AddCommandInboxModule(inbox =>
{
inbox.Contracts.Register<ProcessPaymentCommand>(
"payments.commands.process-payment",
version: 1);
inbox.UseProcessorOptions(new CommandInboxProcessorOptions
{
BatchSize = 50,
LeaseDuration = TimeSpan.FromMinutes(2)
});
});
});The inbox module registers ICommandScheduler and ICommandInboxProcessor. A store module or application registration must provide ICommandInboxWriter, ICommandInboxLeaseStore, and ICommandInboxStateStore.
builder.Services.AddLiteBus(liteBus =>
{
liteBus.AddOutboxModule(outbox =>
{
outbox.Contracts.Register<OrderSubmittedIntegrationEvent>(
"orders.events.order-submitted",
version: 1);
outbox.UseProcessorOptions(new OutboxProcessorOptions
{
BatchSize = 100,
LeaseDuration = TimeSpan.FromMinutes(2)
});
});
});The outbox module registers IOutboxWriter, IIntegrationOutbox, and IOutboxProcessor. It registers a dispatcher only when UseLiteBusEventDispatcher() is called. Broker dispatchers should register IOutboxDispatcher themselves.
var dataSource = NpgsqlDataSource.Create(connectionString);
builder.Services.AddLiteBus(liteBus =>
{
liteBus.AddPostgreSqlCommandInboxStore(postgres =>
{
postgres.UseDataSource(dataSource);
postgres.UseOptions(new PostgreSqlInboxStoreOptions
{
SchemaName = "app",
TableName = "litebus_inbox_commands"
});
});
liteBus.AddPostgreSqlOutboxStore(postgres =>
{
postgres.UseDataSource(dataSource);
postgres.UseOptions(new PostgreSqlOutboxStoreOptions
{
SchemaName = "app",
TableName = "litebus_outbox_messages"
});
});
});Call PostgreSqlInboxSchema.CreateIfNotExistsAsync and PostgreSqlOutboxSchema.CreateIfNotExistsAsync during startup or replace those helpers with migrations owned by the application.
- Query packages do not depend on durable inbox or outbox packages.
- PostgreSQL packages do not depend on EF Core.
- Durable abstractions do not depend on PostgreSQL, broker clients, or hosting packages.
- The command inbox schedules future command execution. The outbox stores facts for later publication.
- Stable durable contracts use names and versions. They do not store assembly-qualified type names.
- Closed generic durable messages are supported when each closed type is registered. Open generic durable contracts are not supported.