LiteBus
CatalogDispatch

Inbox AMQP Dispatch

  • ID: dispatch.inbox.amqp
  • Name: Inbox AMQP dispatch
  • Maturity: GA
  • Summary: Publishes leased inbox envelopes to RabbitMQ or LavinMQ through TransportInboxDispatcher and AmqpTransportModule.

What It Does

AddAmqpTransport(...) registers the horizontal AMQP infrastructure once at the root. InboxModuleBuilder.UseAmqpDispatch(...) wires only TransportInboxDispatchModule, which requires that root module. The inbox processor keeps the durable lease and retry behavior, but the dispatch step publishes to AMQP instead of calling local command handlers.

Common deployment shape is a producer service with inbox storage and processor enabled, plus a separate worker service that consumes the queue and accepts into its own inbox. Because the processor acknowledges completion only after store persist, this path is at-least-once.

Public Surface

services.AddLiteBus(litebus =>
{
    litebus.AddAmqpTransport(new AmqpConnectionOptions
    {
        HostName = "localhost",
        Port = 5672,
        VirtualHost = "/",
        UserName = "guest",
        Password = "guest"
    });

    litebus.AddInbox(inbox =>
    {
        inbox.EnableInboxProcessor();
        inbox.UseAmqpDispatch(
            options =>
            {
                options.DefaultDestination = "commands.exchange";
                options.ResolveRoute = envelope => envelope.ContractName;
                options.Persistent = true;
                options.Mandatory = true;
            });
    });
});
APIRole
InboxModuleBuilder.UseAmqpDispatch(Action<TransportInboxDispatcherOptions>)Registers transport inbox dispatcher that requires the root AMQP transport
TransportInboxDispatcher.DispatchAsync(InboxEnvelope, CancellationToken)Resolves route, maps headers, publishes through ITransportPublisher

TransportInboxDispatcherOptions:

PropertyDefaultRole
DefaultDestination""Exchange name ("" targets default direct exchange)
ContentTypeapplication/jsonMIME value written to publish request
PersistenttrueRequests broker-persistent delivery
MandatoryfalseFails publish when message is unroutable
ResolveRoutenullRoute override delegate per envelope
ValidatePayloadBeforeDispatchfalseDeserializes payload before publish to detect contract mismatch

AmqpConnectionOptions:

PropertyDefaultRole
UrinullFull AMQP URI, overrides host/port/credentials when set
HostNamelocalhostBroker host name
Port5672Broker port
VirtualHost/AMQP virtual host
UserName / Passwordguest / guestBroker credentials
ClientProvidedNamenullConnection display name in broker UI
AutomaticRecoveryEnabledtrueEnables RabbitMQ client reconnect
NetworkRecoveryInterval00:00:05Delay between reconnect attempts
CircuitBreakerconfigured objectSeparate connection and per-exchange publisher breaker thresholds

Packages

PackageRole
LiteBus.Inbox.Dispatch.AmqpInbox AMQP registration extension
LiteBus.Inbox.DispatchShared transport inbox dispatcher
LiteBus.Transport.AmqpAMQP transport adapter and OpenTelemetry registration

Requires

  • dispatch.registration
  • dispatch.transport-core
  • transport.amqp
  • durable-core.inbox

Invariants

  • Only one IInboxDispatcher can be registered in an inbox module builder scope.
  • TransportInboxDispatchModule throws at compose time when no ITransportPublisher is registered.
  • Route resolution order is tenant strategy, then ResolveRoute, then ContractName.
  • Processor semantics remain at-least-once, AMQP publish success alone does not mark completion.

Non-Goals

  • AMQP queue consumption and accept semantics (handled by ingress.amqp).
  • Combining in-process and AMQP dispatch on the same inbox module.
  • Broker-side queue topology management beyond publishing to configured destination and route.

Observability

SignalNameTags
Activitysend {destination}messaging.destination.name, messaging.rabbitmq.destination.routing_key, messaging.message.id
Counterlitebus.transport.circuit_breaker.openlitebus.transport.broker=amqp
Counterlitebus.transport.circuit_breaker.failure_countlitebus.transport.broker=amqp
Histogramlitebus.inbox.processor.dispatch_durationprocessor tags
Counterslitebus.inbox.processor.succeeded / failed / dead_letteredprocessor tags

Register transport signals with AddLiteBusAmqpMetrics() and processor signals with AddLiteBusInboxMetrics().

Test Coverage

Covered

Test methodProject
InboxDispatchExtensions_ShouldRegisterTransportDispatcherLiteBus.Durable.IntegrationTests (Registration/)
ProcessPendingAsync_ShouldPublishLeasedEnvelopeToAmqpQueueLiteBus.Durable.IntegrationTests (Dispatch/Inbox/Amqp/)
ProcessPendingAsync_ShouldPublishToAmqpAndMarkPostgreSqlEnvelopeCompletedLiteBus.Durable.IntegrationTests (Dispatch/Inbox/Amqp/)

Untested

  • Explicit inbox dispatch failure path when broker is unreachable.
  • Mandatory = true unroutable publish behavior in integration tests.
  • Custom route resolver and tenant routing strategy branches.

Out-of-Scope

  • Queue consumer ack and retry semantics.
  • Exchange and binding provisioning lifecycle.

Deep Docs

On this page