RabbitMQ uses the AMQP URI Specification. The RabbitMQ transport requires a connection string to connect to the RabbitMQ broker.
To specify the connection string in code:
configure.UseTransport<NServiceBus.RabbitMQ>(() => "My custom connection string");
By default, the transport will look for a connection string called
<connectionStrings> <add name="NServiceBus/Transport" connectionString="host=broker1"/> </connectionStrings>
To use a custom name for the connection string:
Below is the list of connection string options. When constructing a connection string, these options should be separated by a semicolon.
The host name of the broker.
By default, the guest user can only connect via localhost. If connecting to a remote host, a user name and password must be provided.
<connectionStrings> <add name="NServiceBus/Transport" connectionString="host=myremoteserver; username=myusername; password=mypassword"/> </connectionStrings>
The port where the broker listens.
5671 if the
UseTls setting is set to
true, otherwise the default value is
The virtual host to use.
The user name to use to connect to the broker.
The password to use to connect to the broker.
The interval for the heartbeats between the client and the server.
The number of messages to prefetch when consuming messages from the broker.
Default: The number of configured threads for the transport (as of Version 2.1)
Controls if publisher confirms should be used.
How long the client should wait for publisher confirms, if enabled.
The time to wait before trying to reconnect to the broker if the connection is lost.
For debugging purposes, it can be helpful to increase the
RequestedHeartbeat setting as shown below:
<connectionStrings> <add name="NServiceBus/Transport" connectionString="host=broker1;RequestedHeartbeat=600"/> </connectionStrings>
Increasing this setting can help prevent the connection to the broker from timing out while the code is paused from hitting a breakpoint.
The RabbitMQ transport monitors the connection to the broker and will trigger the critical error action if the connection fails and stays disconnected for the configured amount of time.
Controls the amount of time the transport waits after a failure is detected before triggering the critical error action.
00:02:00 (2 minutes)