LiteBus
CatalogTransport

AMQP Transport

  • ID: transport.amqp
  • Name: AMQP transport
  • Maturity: GA
  • Summary: RabbitMQ and LavinMQ adapter that implements ITransportPublisher and IMessageConsumer with explicit manual acknowledgement semantics.

What It Does

AmqpTransportModule composes AmqpPublisher, AmqpConsumer, and AmqpConnectionManager on top of RabbitMQ.Client. Publish uses exchange (Destination) plus routing key (Route). Consume binds to queue settings from TransportConsumerOptions and projects each delivery into TransportMessage.

AMQP registration includes a transport connectivity diagnostic check and shared transport circuit-breaker metrics tagged with broker value amqp.

RabbitMQ's default exchange has an empty name and routes directly to the queue named by the routing key. LiteBus scopes its publisher circuit by named exchange, or by routing key for the default exchange, so one unavailable default-exchange queue does not reject publications to another queue.

Public Surface

Registration and Runtime Types

APIRole
AmqpTransportModuleRegisters AMQP transport services
IAmqpConnectionManager, AmqpConnectionManagerConnection and channel lifecycle
AmqpPublisher.PublishAsyncPublish message to exchange and route
AmqpConsumer.StartAsyncStart queue consume loop
IAmqpPublisher, IAmqpConsumerAMQP-specific adapter contracts
AmqpConnectivityDiagnosticCheckHost manifest connectivity probe
AmqpTransportConfigurationExceptionInvalid AMQP configuration error

Options

TypePropertyDefaultPurpose
AmqpConnectionOptionsUrinullFull URI override for host and credential fields
AmqpConnectionOptionsHostNamelocalhostBroker host
AmqpConnectionOptionsPort5672Broker port
AmqpConnectionOptionsVirtualHost/AMQP vhost
AmqpConnectionOptionsUserNameguestUsername
AmqpConnectionOptionsPasswordguestPassword
AmqpConnectionOptionsClientProvidedNamenullConnection name visible in broker UI
AmqpConnectionOptionsAutomaticRecoveryEnabledtrueClient recovery toggle
AmqpConnectionOptionsNetworkRecoveryInterval5sReconnect interval
AmqpConnectionOptionsCircuitBreakernew()AMQP breaker threshold and duration
AmqpConsumerOptionsQueueNamerequiredQueue to consume
AmqpConsumerOptionsPrefetchCount1Unacked delivery window
AmqpConsumerOptionsExclusivefalseExclusive consumer
AmqpConsumerOptionsConsumerTagnullExplicit consumer tag
AmqpConsumerOptionsDeclareQueuetrueDeclare queue before consume
AmqpConsumerOptionsDurableQueuetrueDurable queue declaration
AmqpConsumerOptionsQueueArgumentsnullQueue declaration arguments

Ack Mapping

Transport callAMQP action
AcceptAsyncbasic.ack
DiscardAsyncbasic.nack with requeue=false
ReturnToQueueAsyncbasic.nack with requeue=true

Packages

  • LiteBus.Transport.Amqp
  • LiteBus.Transport.Amqp.Extensions.OpenTelemetry

Requires

  • transport.publish-consume-contracts
  • transport.manual-acknowledgement
  • transport.single-broker-registration

Invariants

  • AMQP is exclusive per process; adding a second broker module fails standard duplicate-service composition validation.
  • TransportMessage ack delegates map directly to basic.ack and basic.nack.
  • Circuit breaker and metrics register once per module configuration using broker tag amqp.
  • Publisher circuits use the named exchange as their scope. The empty-name default exchange uses its queue routing key.

Non-Goals

  • Running multiple broker adapters in one process.
  • Owning production exchange and queue topology outside declared consumer queue settings.
  • Inbox acceptance, durable idempotency, or processor retries.

Observability

Metrics

ItemValue
MeterLiteBus.Transport
Broker taglitebus.transport.broker="amqp"
Gaugeslitebus.transport.circuit_breaker.open, litebus.transport.circuit_breaker.failure_count
OpenTelemetry registrationAddLiteBusTransportMetrics() or AddLiteBusAmqpMetrics()

Tracing

  • Activity source: LiteBus.Transport
  • Send span: send {destination} with messaging.system=rabbitmq
  • Process span: process {destination} with messaging.system=rabbitmq

Diagnostics

  • Diagnostic check id: transport.amqp.connectivity
  • Type: AmqpConnectivityDiagnosticCheck

Test Coverage

Covered

Test methodProject
PublishAsync_ThenConsume_AcknowledgesMessageLiteBus.Transport.IntegrationTests (Amqp/)
ConsumeAsync_NackWithRequeue_RedeliversMessageLiteBus.Transport.IntegrationTests (Amqp/)
PublishAsync_WithLiteBusHeaders_PreservesHeaderValuesLiteBus.Transport.IntegrationTests (Amqp/)
PublishAsync_AfterConnectionClosed_RecreatesPublishChannelLiteBus.Transport.IntegrationTests (Amqp/)
GetConnectionAsync_AfterConnectionClosed_RecreatesWorkingConnectionLiteBus.Transport.IntegrationTests (Amqp/)
ShouldNack_when_handlerFails_ShouldReturnTrueLiteBus.Transport.UnitTests (Amqp/)
RecordFailure_until_threshold_ShouldOpenCircuitAndExposeFailureCountLiteBus.Transport.UnitTests (Amqp/)
RecordSuccess_after_failures_ShouldCloseCircuitLiteBus.Transport.UnitTests (Amqp/)
PublishThroughRabbitMq_ShouldAcceptProcessAndDispatchCommandLiteBus.Durable.IntegrationTests (Ingress/Amqp/)
PublishThroughLavinMq_ShouldAcceptProcessAndDispatchCommandLiteBus.Durable.IntegrationTests (Ingress/Amqp/)

Untested

  • AmqpConnectivityDiagnosticCheck behavior in host manifest tests.
  • Exported gauge samples that assert broker tag amqp.
  • Channel-close timing window where handler finishes while channel is closing.

Out-of-Scope

  • Multi-broker failover.
  • Production topology automation beyond queue declaration flags.

Deep Docs

On this page