C# Class RabbitMQ.Client.ConnectionFactory

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

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.HostName = hostName; factory.Port = 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");

The same example, written more compactly with AMQP URIs:

ConnectionFactory factory = new ConnectionFactory(); factory.Uri = "amqp://localhost"; IConnection conn = factory.CreateConnection(); ...

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

Note that the Uri property takes a string representation of an AMQP URI. Omitted URI parts will take default values. The host part of the URI cannot be omitted and URIs of the form "amqp://foo/" (note the trailling slash) also represent the default virtual host. The latter issue means that virtual hosts with an empty name are not addressable.

Exibir arquivo Open project: rabbitmq/rabbitmq-dotnet-client Class Usage Examples

Public Properties

Property Type Description
DefaultAuthMechanisms IList

Property Details

DefaultAuthMechanisms public_oe static_oe property

Default SASL auth mechanisms to use.
public static IList DefaultAuthMechanisms
return IList