RabbitMQ Transport

NuGet Package NServiceBus.RabbitMQ (7-pre)
This page targets a pre-release version. Pre-releases are subject to change and samples are not guaranteed to be fully functional.

Provides support for sending messages over RabbitMQ using the RabbitMQ .NET Client.

Hosting options

The transport is compatible with RabbitMQ broker version 3.4 or higher either self-hosted or running on Amazon MQ or CloudAMQP.

The transport is not compatible with RabbitMQ broker version 3.3.X and below.

Transport at a glance

TransactionsNone, ReceiveOnly
Large message bodiesBroker can handle arbitrary message size within available resources, very large messages via data bus
Scale-outCompeting consumer
Scripted DeploymentNot supported

Configuring the endpoint

To use RabbitMQ as the underlying transport:

    new RabbitMQTransport(Topology.Conventional, "host=localhost"));

The RabbitMQ transport requires a connection string to connect to the broker. See connection settings for options on how to provide the connection string.

Routing topology

Routing topologies are used to control how queues, exchanges, and bindings are created on the RabbitMQ broker. Since version 5, selecting a routing topology is mandatory. For new deployments the ConventionalRoutingTopology (previously the default) should be selected:

var transport = new RabbitMQTransport(Topology.Conventional, "host=localhost");


See the routing topology documentation for further details.

Advantages and disadvantages


  • Provides native reliability and high-availability features.
  • Offers a native publish-subscribe mechanism; therefore it doesn't require NServiceBus persistence for storing event subscriptions.
  • Wide range of supported clients allows for integrating the system with applications written in other languages using native RabbitMQ features.
  • Supports the competing consumers pattern out of the box. Messages are received by instances in a round-robin fashion without additional configuration.


  • Doesn't handle network partitions well; partitioning across a WAN requires dedicated features.
  • Requires careful consideration for duplicate messages, e.g. using the outbox feature or making all endpoints idempotent.
  • Many organizations don't have the same level of expertise with RabbitMQ as with other technologies, such as SQL Server, so it may require additional training.
  • May require additional costs of commercial RabbitMQ license and support.

Controlling delivery mode

In AMQP the delivery_mode controls how the broker treats the message from a durability standpoint. NServiceBus will default to persistent in order to prevent message loss. To optimize for higher throughput this can be changed to non-persistent.

Any failure in transmission or issues in the broker will result in the message being lost

To request non-persistent delivery use the following {Send|Publish|Reply}Options as shown below.

var options = new SendOptions();


await context.Send(new MyMessage(), options);


Related Articles

Last modified