LiteBus
CatalogDispatch

Dispatcher Registration

  • ID: dispatch.registration
  • Name: Dispatcher registration
  • Maturity: GA
  • Summary: Register exactly one inbox and one outbox dispatcher per module through nested Use*Dispatch extensions on composite module builders.

What It Does

Dispatch adapters register as child modules of InboxModule or OutboxModule. InboxModuleBuilder.RegisterDispatcher and OutboxModuleBuilder.RegisterDispatcher accept an IInboxDispatcherModule or IOutboxDispatcherModule implementation. Each broker-specific Use*Dispatch extension constructs the matching dispatcher module, which requires a transport registered once at the root.

Calling more than one dispatcher registration method on the same builder throws LiteBusConfigurationException at compose time. Module graph validation ensures required parents and transports exist before any dispatcher module builds.

Packages

PackageRole
LiteBus.Inbox.AbstractionsIInboxDispatcherModule contract
LiteBus.Outbox.AbstractionsIOutboxDispatcherModule contract
LiteBus.Inbox, LiteBus.OutboxConcrete module builder surfaces
LiteBus.Inbox.Dispatch.* / LiteBus.Outbox.Dispatch.*Concrete dispatcher modules

Requires

  • durable-core.inbox or durable-core.outbox (parent module must be registered)
  • For in-process dispatch: mediator.commands (inbox) or mediator.events (outbox)
  • For transport dispatch: matching transport.* broker module registered at the root

Invariants

  • Exactly one IInboxDispatcher and one IOutboxDispatcher per respective module configuration scope.
  • Dispatcher sub-modules declare IRequires<InboxModule> or IRequires<OutboxModule> for topological ordering.
  • Transport dispatch modules declare the matching root transport module as a graph dependency.

Non-Goals

  • Does not register storage, ingress, or processor loops (those are sibling child modules).
  • Does not allow combining in-process and broker dispatch on the same axis in one module (choose one execution target).
  • Does not provide a unified UseTransportDispatch(TransportKind, ...) meta-API; each broker is a separate package.

Public Surface

services.AddLiteBus(litebus =>
{
    litebus.AddKafkaTransport(new KafkaTransportOptions { BootstrapServers = "localhost:9092" });

    litebus.AddInbox(inbox =>
    {
        inbox.EnableInboxProcessor();
        inbox.UseInProcessDispatch();
    });

    litebus.AddOutbox(outbox =>
    {
        outbox.EnableOutboxProcessor();
        outbox.UseKafkaDispatch(options => options.DefaultDestination = "events");
    });
});

InboxModuleBuilder.RegisterDispatcher(IInboxDispatcherModule)

PackageLiteBus.Inbox
ReturnsInboxModuleBuilder for chaining
RoleLow-level registration; stores the dispatcher child module for InboxModule.Build()

Throws LiteBusConfigurationException when a second dispatcher module is registered on the same builder.

OutboxModuleBuilder.RegisterDispatcher(IOutboxDispatcherModule)

PackageLiteBus.Outbox
ReturnsOutboxModuleBuilder for chaining
RoleLow-level registration; stores the dispatcher child module for OutboxModule.Build()

InboxModuleBuilder.UseInProcessDispatch()

PackageLiteBus.Inbox.Dispatch.InProcess
RegistersCommandInboxDispatchModule to CommandInboxDispatcher as IInboxDispatcher
RequiresAddCommands and contract registration for handled command types

OutboxModuleBuilder.UseInProcessDispatch()

PackageLiteBus.Outbox.Dispatch.InProcess
RegistersEventOutboxDispatchModule to EventOutboxDispatcher as IOutboxDispatcher
RequiresAddEvents and contract registration for published event types

Broker Use*Dispatch Extensions (Inbox and Outbox)

ExtensionPackageRequired root transport
UseAmqpDispatch(configure)*.Dispatch.AmqpAddAmqpTransport(...)
UseAzureServiceBusDispatch(configure)*.Dispatch.AzureServiceBusAddAzureServiceBusTransport(...)
UseAwsSqsDispatch(configure)*.Dispatch.AwsSqsAddAwsSqsTransport(...)
UseKafkaDispatch(configure)*.Dispatch.KafkaAddKafkaTransport(...)
UseInMemoryDispatch(configure?)*.Dispatch.InMemoryAddInMemoryTransport()

Each extension builds TransportInboxDispatcherOptions or TransportOutboxDispatcherOptions, wraps TransportInboxDispatchModule or TransportOutboxDispatchModule, and calls RegisterDispatcher.

Registration runs inside AddInbox(...) or AddOutbox(...) alongside storage and processor enablement. v6 removed flat top-level dispatcher registrars; compose through the parent module builder only.

Observability

SignalSourceWhen emitted
No registration-time metrics:Compose is silent until the processor runs
send {destination} activityLiteBusTransportTelemetry.PublishOperationName on activity source LiteBus.TransportConcrete broker publisher around the SDK send call
litebus.inbox.processor.dispatch_duration histogramLiteBusInboxTelemetry.ProcessorDispatchDurationInstrumentNameProcessor wraps every inbox DispatchAsync call
litebus.outbox.processor.dispatch_duration histogramLiteBusOutboxTelemetry.ProcessorDispatchDurationInstrumentNameProcessor wraps every outbox DispatchAsync call
litebus.inbox.processor.succeeded / failed / dead_letteredInbox processor pass countersAfter dispatch returns or throws
litebus.outbox.processor.published / failed / dead_letteredOutbox processor pass countersAfter dispatch returns or throws
litebus.transport.circuit_breaker.*LiteBusTransportTelemetry meterBroker publish failures on transport dispatch paths

Register inbox and outbox meters through AddLiteBusInboxMetrics() and AddLiteBusOutboxMetrics(). Register the shared transport meter through AddLiteBusTransportMetrics(). AMQP applications may use the compatibility alias AddLiteBusAmqpMetrics().

Analyzers

  • LB1014: Inbox or outbox processor enabled without a dispatcher in the same module builder scope.

Deep Docs

Test Coverage

Covered

Test methodProject
AddInboxInProcessDispatcher_ShouldRegisterCommandInboxDispatcherLiteBus.Inbox.UnitTests (Dispatch/InProcess/)
AddInboxInProcessDispatcher_WhenCalledTwice_ShouldThrowLiteBus.Inbox.UnitTests (Dispatch/InProcess/)
AddInboxInProcessDispatcher_WhenAnotherDispatcherRegistered_ShouldThrowLiteBus.Inbox.UnitTests (Dispatch/InProcess/)
AddInboxModule_WithNestedStorageAndDispatcher_ShouldResolveInboxServicesLiteBus.Inbox.UnitTests
AddOutboxInProcessDispatcher_ShouldRegisterInProcessOutboxDispatcherLiteBus.Outbox.UnitTests (Dispatch/InProcess/)
AddOutboxInProcessDispatcher_WhenCalledTwice_ShouldThrowLiteBus.Outbox.UnitTests (Dispatch/InProcess/)
AddOutboxInProcessDispatcher_WhenAnotherDispatcherRegistered_ShouldThrowLiteBus.Outbox.UnitTests (Dispatch/InProcess/)
InboxDispatchExtensions_ShouldRegisterTransportDispatcherLiteBus.Durable.IntegrationTests (Registration/)
InboxModuleBuilderAwsDispatchExtensions_should_expose_use_aws_sqs_dispatchLiteBus.Inbox.UnitTests (Dispatch/AwsSqs/)
OutboxDispatchExtensions_ShouldRegisterTransportDispatcherLiteBus.Durable.IntegrationTests (Registration/)
UseAmqpDispatch_WithAmqpTransportModule_ShouldRegisterTransportOutboxDispatcherLiteBus.Durable.IntegrationTests (Dispatch/Outbox/Amqp/)
ProcessorBackgroundService_WhenDispatcherMissing_ShouldThrowOnBuildLiteBus.Inbox.UnitTests

Untested

  • Autofac AddLiteBus registration parity.
  • Duplicate IInboxDispatcher or IOutboxDispatcher via low-level registry bypasses.
  • LB1014 analyzer behavior in dispatch test projects (covered in analyzers unit tests).

Out-of-Scope

  • Registering storage, ingress, or processor loops (sibling child modules)
  • Combining in-process and broker dispatch on the same inbox or outbox module
  • Unified UseTransportDispatch(TransportKind, ...) meta-API across brokers
  • Flat v5-style top-level dispatcher registrars (removed in v6)

On this page