void TryToConnect(object timer)
{
if (timer != null)
{
((Timer) timer).Dispose();
}
Logger.Debug("Trying to connect");
if (disposed)
{
return;
}
var success = false;
try
{
connection = connectionFactory.CreateConnection(purpose);
success = true;
}
catch (System.Net.Sockets.SocketException socketException)
{
LogException(socketException);
}
catch (BrokerUnreachableException brokerUnreachableException)
{
LogException(brokerUnreachableException);
}
if (success)
{
connection.ConnectionShutdown += OnConnectionShutdown;
Logger.InfoFormat("Connected to RabbitMQ. Broker: '{0}', Port: {1}, VHost: '{2}'",
connectionFactory.Configuration.HostConfiguration.Host,
connectionFactory.Configuration.HostConfiguration.Port,
connectionFactory.Configuration.VirtualHost);
}
else
{
Logger.ErrorFormat("Failed to connected to the Broker. Retrying in {0}", retryDelay);
StartTryToConnect();
}
}
bool IsConnected