Table of Contents

Interface IConnectionFactory

Namespace
RabbitMQ.Client
Assembly
RabbitMQ.Client.dll
public interface IConnectionFactory

Properties

ClientProperties

Dictionary of client properties to be sent to the server.

IDictionary<string, object?> ClientProperties { get; set; }

Property Value

IDictionary<string, object>

ClientProvidedName

Default client provided name to be used for connections.

string? ClientProvidedName { get; set; }

Property Value

string

ConsumerDispatchConcurrency

Set to a value greater than one to enable concurrent processing. For a concurrency greater than one IAsyncBasicConsumer will be offloaded to the worker thread pool so it is important to choose the value for the concurrency wisely to avoid thread pool overloading. IAsyncBasicConsumer can handle concurrency much more efficiently due to the non-blocking nature of the consumer. Defaults to 1.

ushort ConsumerDispatchConcurrency { get; set; }

Property Value

ushort

Remarks

For concurrency greater than one this removes the guarantee that consumers handle messages in the order they receive them. In addition to that consumers need to be thread/concurrency safe.

ContinuationTimeout

Amount of time protocol operations (e.g.

queue.declare
) are allowed to take before timing out.
TimeSpan ContinuationTimeout { get; set; }

Property Value

TimeSpan

CredentialsProvider

ICredentialsProvider used to obtain username and password.

ICredentialsProvider? CredentialsProvider { get; set; }

Property Value

ICredentialsProvider

HandshakeContinuationTimeout

Amount of time protocol handshake operations are allowed to take before timing out.

TimeSpan HandshakeContinuationTimeout { get; set; }

Property Value

TimeSpan

Password

Password to use when authenticating to the server.

string Password { get; set; }

Property Value

string

RequestedChannelMax

Maximum channel number to ask for.

ushort RequestedChannelMax { get; set; }

Property Value

ushort

RequestedFrameMax

Frame-max parameter to ask for (in bytes).

uint RequestedFrameMax { get; set; }

Property Value

uint

RequestedHeartbeat

Heartbeat setting to request.

TimeSpan RequestedHeartbeat { get; set; }

Property Value

TimeSpan

Uri

Sets or gets the AMQP Uri to be used for connections.

Uri Uri { get; set; }

Property Value

Uri

UserName

Username to use when authenticating to the server.

string UserName { get; set; }

Property Value

string

VirtualHost

Virtual host to access during this connection.

string VirtualHost { get; set; }

Property Value

string

Methods

AuthMechanismFactory(IEnumerable<string>)

Given a list of mechanism names supported by the server, select a preferred mechanism, or null if we have none in common.

IAuthMechanismFactory? AuthMechanismFactory(IEnumerable<string> mechanismNames)

Parameters

mechanismNames IEnumerable<string>

Returns

IAuthMechanismFactory

CreateConnectionAsync(IEnumerable<AmqpTcpEndpoint>, string, CancellationToken)

Asynchronously create a connection using a list of endpoints. The selection behaviour can be overridden by configuring the EndpointResolverFactory.

Task<IConnection> CreateConnectionAsync(IEnumerable<AmqpTcpEndpoint> endpoints, string clientProvidedName, CancellationToken cancellationToken = default)

Parameters

endpoints IEnumerable<AmqpTcpEndpoint>

List of endpoints to use for the initial connection and recovery.

clientProvidedName string

Application-specific connection name, will be displayed in the management UI if RabbitMQ server supports it. This value doesn't have to be unique and cannot be used as a connection identifier, e.g. in HTTP API requests. This value is supposed to be human-readable.

cancellationToken CancellationToken

Cancellation token for this connection

Returns

Task<IConnection>

Open connection

Exceptions

BrokerUnreachableException

When no hostname was reachable.

CreateConnectionAsync(IEnumerable<AmqpTcpEndpoint>, CancellationToken)

Asynchronously create a connection using a list of endpoints. The selection behaviour can be overridden by configuring the EndpointResolverFactory.

Task<IConnection> CreateConnectionAsync(IEnumerable<AmqpTcpEndpoint> endpoints, CancellationToken cancellationToken = default)

Parameters

endpoints IEnumerable<AmqpTcpEndpoint>

List of endpoints to use for the initial connection and recovery.

cancellationToken CancellationToken

Cancellation token for this connection

Returns

Task<IConnection>

Open connection

Exceptions

BrokerUnreachableException

When no hostname was reachable.

CreateConnectionAsync(IEnumerable<string>, string, CancellationToken)

Asynchronously connects to the first reachable hostname from the list.

Task<IConnection> CreateConnectionAsync(IEnumerable<string> hostnames, string clientProvidedName, CancellationToken cancellationToken = default)

Parameters

hostnames IEnumerable<string>

List of host names to use

clientProvidedName string

Application-specific connection name, will be displayed in the management UI if RabbitMQ server supports it. This value doesn't have to be unique and cannot be used as a connection identifier, e.g. in HTTP API requests. This value is supposed to be human-readable.

cancellationToken CancellationToken

Cancellation token for this connection

Returns

Task<IConnection>

Open connection

CreateConnectionAsync(IEnumerable<string>, CancellationToken)

Asynchronously connects to the first reachable hostname from the list.

Task<IConnection> CreateConnectionAsync(IEnumerable<string> hostnames, CancellationToken cancellationToken = default)

Parameters

hostnames IEnumerable<string>

List of host names to use

cancellationToken CancellationToken

Cancellation token for this connection

Returns

Task<IConnection>

Open connection

CreateConnectionAsync(string, CancellationToken)

Asynchronously create a connection to the specified endpoint.

Task<IConnection> CreateConnectionAsync(string clientProvidedName, CancellationToken cancellationToken = default)

Parameters

clientProvidedName string

Application-specific connection name, will be displayed in the management UI if RabbitMQ server supports it. This value doesn't have to be unique and cannot be used as a connection identifier, e.g. in HTTP API requests. This value is supposed to be human-readable.

cancellationToken CancellationToken

Cancellation token for this connection

Returns

Task<IConnection>

Open connection

CreateConnectionAsync(CancellationToken)

Asynchronously create a connection to the specified endpoint.

Task<IConnection> CreateConnectionAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token for this connection

Returns

Task<IConnection>