public class ConnectionFactory

Summary

Main entry point to the RabbitMQ .NET AMQP client API. Constructs IConnection instances.

Remarks

A simple example of connecting to a broker:

                 ConnectionFactory factory = new ConnectionFactory();
                 //
                 // The next six lines are optional:
                 factory.UserName = ConnectionFactory.DefaultUser;
                 factory.Password = ConnectionFactory.DefaultPass;
                 factory.VirtualHost = ConnectionFactory.DefaultVHost;
                 factory.Protocol = Protocols.FromEnvironment();
                 factory.HostName = hostName;
                 factory.PortNumber = AmqpTcpEndpoint.UseDefaultPort;
                 //
                 IConnection conn = factory.CreateConnection();
                 //
                 IModel ch = conn.CreateModel();
                 //
                 // ... use ch's IModel methods ...
                 //
                 ch.Close(Constants.ReplySuccess, "Closing the channel");
                 conn.Close(Constants.ReplySuccess, "Closing the connection");
            

Please see also the API overview and tutorial in the User Guide.

Some of the static methods described below take, as a convenience, a System.Uri instance representing an AMQP server address. The use of Uri here is not standardised - Uri is simply a convenient container for internet-address-like components. In particular, the Uri "Scheme" property is ignored: only the "Host" and "Port" properties are extracted.

Field Summary

Flags Type Name Summary
public IDictionary ClientProperties

Dictionary of client properties to be sent to the server

public const ushort DefaultChannelMax

Default value for the desired maximum channel number, with zero meaning unlimited (value: 0)

public const uint DefaultFrameMax

Default value for the desired maximum frame size, with zero meaning unlimited (value: 0)

public const ushort DefaultHeartbeat

Default value for desired heartbeat interval, in seconds, with zero meaning none (value: 0)

public const string DefaultPass

Default password (value: "guest")

public const string DefaultUser

Default user name (value: "guest")

public const string DefaultVHost

Default virtual host (value: "/")

public string HostName

The host to connect to

public string Password

Password to use when authenticating to the server

public int Port

The port to connect on. AmqpTcpEndpoint.UseDefaultPort indicates the default for the protocol should be used.

public IProtocol Protocol

The AMQP protocol to be used

public ushort RequestedChannelMax

Maximum channel number to ask for

public uint RequestedFrameMax

Frame-max parameter to ask for (in bytes)

public ushort RequestedHeartbeat

Heartbeat setting to request (in seconds)

public SslOption Ssl

Ssl options setting

public string UserName

Username to use when authenticating to the server

public string VirtualHost

Virtual host to access during this connection

Property Summary

Flags Type Name Summary
public string Address (rw)

(undocumented)

public AmqpTcpEndpoint Endpoint (rw)

(undocumented)

Constructor Summary

Flags Name Summary
public ConnectionFactory()

Construct a fresh instance, with all fields set to their respective defaults.

Method Summary

Flags Name Summary
public virtual IConnection CreateConnection(int maxRedirects)

Create a connection to the first available endpoint in the list provided. Up to a maximum of maxRedirects broker-originated redirects are permitted for each endpoint tried.

public virtual IConnection CreateConnection()

Create a connection to the specified endpoint No broker-originated redirects are permitted.

Field Detail

public IDictionary ClientProperties

Summary

Dictionary of client properties to be sent to the server

public const ushort DefaultChannelMax

Summary

Default value for the desired maximum channel number, with zero meaning unlimited (value: 0)

public const uint DefaultFrameMax

Summary

Default value for the desired maximum frame size, with zero meaning unlimited (value: 0)

public const ushort DefaultHeartbeat

Summary

Default value for desired heartbeat interval, in seconds, with zero meaning none (value: 0)

public const string DefaultPass

Summary

Default password (value: "guest")

public const string DefaultUser

Summary

Default user name (value: "guest")

public const string DefaultVHost

Summary

Default virtual host (value: "/")

public string HostName

Summary

The host to connect to

public string Password

Summary

Password to use when authenticating to the server

public int Port

Summary

The port to connect on. AmqpTcpEndpoint.UseDefaultPort indicates the default for the protocol should be used.

public IProtocol Protocol

Summary

The AMQP protocol to be used

public ushort RequestedChannelMax

Summary

Maximum channel number to ask for

public uint RequestedFrameMax

Summary

Frame-max parameter to ask for (in bytes)

public ushort RequestedHeartbeat

Summary

Heartbeat setting to request (in seconds)

public SslOption Ssl

Summary

Ssl options setting

public string UserName

Summary

Username to use when authenticating to the server

public string VirtualHost

Summary

Virtual host to access during this connection

Property Detail

public string Address (rw)

public AmqpTcpEndpoint Endpoint (rw)

Constructor Detail

ConnectionFactory

public ConnectionFactory()

Summary

Construct a fresh instance, with all fields set to their respective defaults.

Method Detail

CreateConnection

public virtual IConnection CreateConnection(int maxRedirects)

Flags public virtual
Return type IConnection
Parameters
Name Type
maxRedirects int

Summary

Create a connection to the first available endpoint in the list provided. Up to a maximum of maxRedirects broker-originated redirects are permitted for each endpoint tried.

CreateConnection

public virtual IConnection CreateConnection()

Flags public virtual
Return type IConnection

Summary

Create a connection to the specified endpoint No broker-originated redirects are permitted.