RabbitMQ Transport Upgrade Version 6 to 7

Component: RabbitMQ Transport
This page targets a pre-release version. Pre-releases are subject to change and samples are not guaranteed to be fully functional.

Timeout manager

The timeout manager has been removed from core which makes timeout manager backward compatibility mode obsolete. If backward compatibility mode was enabled these APIs must be removed.

Configuring the RabbitMQ transport

To use the RabbitMQ transport for NServiceBus, create a new instance of the RabbitMQTransport and pass it to EndpointConfiguration.UseTransport.

Instead of:

var transport = endpointConfiguration.UseTransport<RabbitMQTransport>();


var transport = new RabbitMQTransport(Topology.Conventional, connectionString);

The mandatory configuration settings, the topology and the connection string, are now required to construct the instance of the transport definition class.

The existing API surface with UseTransport<T>() is supported for NServiceBus version 8 via a shim API to ease migration to the new version. However, it is recommended to switch to the new transport configuration API to prepare for future upgrades of NServiceBus.

Certificate path and passphrase

The certificate file path and passphrase can now be passed only via the connection string. When configuring a secure connection via the API, the only option is to pass an instance of the X505Certificate2 class. This instance can be constructed using a path and passphrase.

Instead of this code:

var transport = endpointConfiguration.UseTransport<RabbitMQTransport>();
transport.SetClientCertificate("path", "password");

Use this:

var transport = new RabbitMQTransport(Topology.Conventional, "host=localhost")
    ClientCertificate = new X509Certificate2("path", "password")


Prefetch count

The two prefetch count settings have been replaced with a single setting that uses a callback. Instead of either of these APIs:

var transport = endpointConfiguration.UseTransport<RabbitMQTransport>();


Use one of these:

var transportWithFixedPrefetchCount = new RabbitMQTransport(Topology.Conventional, "host=localhost")
    PrefetchCountCalculation = _ => 100


var transportWithConcurrencyBasedPrefetchCount = new RabbitMQTransport(Topology.Conventional, "host=localhost")
    PrefetchCountCalculation = concurrency => concurrency * 7

Disabling the durable exchanges and queues

Disabling the durable exchanges and queues has been moved to the constructor of the topology classes, ConventionalRoutingTopology and DirectRoutingTopology. In order to set the value of that parameter use the variant of the RabbitMQTransport constructor that accepts an instance of the topology.

Configuration options

The RabbitMQ transport configuration options that have not changed have been moved to the RabbitMQTransport class. See the following table for further information:

Version 6 configuration optionVersion 7 configuration option

Related Articles

Last modified