Interface IRabbitMQConnectionBuilder
Builder interface for configuring RabbitMQ connection settings.
public interface IRabbitMQConnectionBuilder
- Extension Methods
Remarks
Provides methods for setting the host, port, virtual host, credentials, and connection string for RabbitMQ transport connections.
Methods
AutomaticRecovery(bool, TimeSpan?)
Configures automatic connection recovery behavior.
IRabbitMQTransportBuilder AutomaticRecovery(bool enabled, TimeSpan? networkRecoveryInterval = null)
Parameters
enabledboolWhether automatic connection recovery is enabled.
networkRecoveryIntervalTimeSpan?The interval between network recovery attempts. When null, the existing configured value is retained (default 10 seconds).
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Exceptions
- ArgumentOutOfRangeException
Thrown when
networkRecoveryIntervalis negative or zero.
ConnectionString(string)
Sets the AMQP connection string (alternative to individual connection properties).
IRabbitMQTransportBuilder ConnectionString(string connectionString)
Parameters
connectionStringstringThe AMQP connection string (e.g., "amqp://user:pass@host:port/vhost").
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Remarks
When a connection string is provided, it takes precedence over individual HostName(string), Port(int), VirtualHost(string), and Credentials(string, string) settings.
Exceptions
- ArgumentException
Thrown when
connectionStringis null or whitespace.
Credentials(string, string)
Sets the credentials for authentication.
IRabbitMQTransportBuilder Credentials(string username, string password)
Parameters
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Exceptions
- ArgumentException
Thrown when
usernameis null or whitespace.
HostName(string)
Sets the RabbitMQ host name.
IRabbitMQTransportBuilder HostName(string hostName)
Parameters
hostNamestringThe host name or IP address.
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Exceptions
- ArgumentException
Thrown when
hostNameis null or whitespace.
Port(int)
Sets the RabbitMQ port.
IRabbitMQTransportBuilder Port(int port)
Parameters
portintThe port number (typically 5672 for AMQP, 5671 for AMQPS).
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Exceptions
- ArgumentOutOfRangeException
Thrown when
portis not between 1 and 65535.
VirtualHost(string)
Sets the virtual host.
IRabbitMQTransportBuilder VirtualHost(string vhost)
Parameters
vhoststringThe virtual host path.
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Exceptions
- ArgumentException
Thrown when
vhostis null or whitespace.