Interface IRabbitMQRoutingBuilder
Builder interface for configuring RabbitMQ message routing and SSL.
public interface IRabbitMQRoutingBuilder
- Extension Methods
Remarks
Provides methods for mapping message types to exchanges and queues, setting name prefixes, and enabling SSL/TLS connections.
Methods
MapExchange<TMessage>(string)
Maps a message type to a specific exchange for routing.
IRabbitMQTransportBuilder MapExchange<TMessage>(string exchange) where TMessage : class
Parameters
exchangestringThe target exchange name.
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Type Parameters
TMessageThe message type to map.
Exceptions
- ArgumentException
Thrown when
exchangeis null or whitespace.
MapQueue<TMessage>(string)
Maps a message type to a specific queue for routing.
IRabbitMQTransportBuilder MapQueue<TMessage>(string queue) where TMessage : class
Parameters
queuestringThe target queue name.
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Type Parameters
TMessageThe message type to map.
Exceptions
- ArgumentException
Thrown when
queueis null or whitespace.
RequireTls(bool)
Sets whether an unencrypted broker connection is refused.
IRabbitMQTransportBuilder RequireTls(bool required)
Parameters
requiredbooltrue to refuse to build a connection factory that would connect in the clear; false to permit one. Defaults to refusing.
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Examples
// A development broker with no certificate:
rabbit.ConnectionString("amqp://guest:guest@localhost:5672").RequireTls(false);
Remarks
The refusal happens when the connection factory is built, so a plaintext registration fails where
it is wired rather than at the first message. A connection carries TLS when its connection string
uses the amqps scheme or when UseSsl(Action<RabbitMQSslOptions>?) has been called.
Passing false permits credentials and message payloads to travel in the clear. It exists for local brokers and test fixtures, not for anything holding real data.
UseSsl(Action<RabbitMQSslOptions>?)
Enables SSL/TLS for the connection.
IRabbitMQTransportBuilder UseSsl(Action<RabbitMQSslOptions>? configure = null)
Parameters
configureAction<RabbitMQSslOptions>Optional action to configure SSL options.
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
WithExchangePrefix(string)
Sets a prefix to be applied to all exchange names.
IRabbitMQTransportBuilder WithExchangePrefix(string prefix)
Parameters
prefixstringThe exchange name prefix (e.g., "myapp-prod-").
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Exceptions
- ArgumentException
Thrown when
prefixis null or whitespace.
WithQueuePrefix(string)
Sets a prefix to be applied to all queue names.
IRabbitMQTransportBuilder WithQueuePrefix(string prefix)
Parameters
prefixstringThe queue name prefix (e.g., "myapp-prod-").
Returns
- IRabbitMQTransportBuilder
The builder for chaining.
Exceptions
- ArgumentException
Thrown when
prefixis null or whitespace.