RabbitMQ Transport Upgrade Version 6 to 7

Component: RabbitMQ Transport
This page targets a pre-release version and is subject to change prior to the final release.

Timeout manager

The timeout manager is removed from core which makes timeout manager backwards compatibility mode obsolete. If backwards compatibility mode was enabled these APIs must be removed.

Configuring 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>();
transport.ConnectionString(connectionString);

Use:

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

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

Certificate path and passphrase

Certificate file path and passphrase can now be only passed via the connection string. When configuring secure connection via API the only option is to pass an instance of the X505Certificate2 class. This instance can be constructed using 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")
};

endpointConfiguration.UseTransport(transport);

Prefetch count

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

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

transport.PrefetchCount(100);
//or
transport.PrefetchMultiplier(7);

Use one of these:

var transportWithFixedPrefetchCount = new RabbitMQTransport(Topology.Conventional, "host=localhost")
{
    PrefetchCountCalculation = _ => 100
};
endpointConfiguration.UseTransport(transportWithFixedPrefetchCount);

//or

var transportWithConcurrencyBasedPrefetchCount = new RabbitMQTransport(Topology.Conventional, "host=localhost")
{
    PrefetchCountCalculation = concurrency => concurrency * 7
};
endpointConfiguration.UseTransport(transportWithConcurrencyBasedPrefetchCount);

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 been changed have been moved to the RabbitMQTransport class. See the following table for further information:

Version 6 configuration optionVersion 7 configuration option
CustomMessageIdStrategyMessageIdStrategy
DisableRemoteCertificateValidationValidateRemoteCertificate
SetClientCertificateClientCertificate
SetHeartbeatIntervalHeartbeatInterval
SetNetworkRecoveryIntervalNetworkRecoveryInterval
TimeToWaitBeforeTriggeringCircuitBreakerTimeToWaitBeforeTriggeringCircuitBreaker
UseExternalAuthMechanismUseExternalAuthMechanism

Related Articles


Last modified