Skip to content

Instantly share code, notes, and snippets.

@agilejon
Created November 12, 2013 04:44
Show Gist options
  • Save agilejon/7425595 to your computer and use it in GitHub Desktop.
Save agilejon/7425595 to your computer and use it in GitHub Desktop.
public void InitializeRabbitConnection()
{
ConnectionFactory = new ConnectionFactory()
{
HostName = "localhost",
Port = 5672,
UserName = "myapp",
Password = "password",
RequestedHeartbeat = 4, // heartbeat is what lets your code detect problems communicating with
// the RabbitMQ server. A heartbeat of 4 will cause the server to send
// a heartbeat 'ping' message every 4 seconds. If the client has not
// received a ping in 8 seconds (heartbeat*2) then it will consider the
// connection to be bad and throw a ConnectionShutdown event.
};
var SingletonConnection = ConnectionFactory.CreateConnection();
SingletonConnection.ConnectionShutdown += SingletonConnection_ConnectionShutdown; // handle disconnects
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment