protected virtual IConnection CreateBareConnection() { try { var connectionName = ObtainNewConnectionName(); var rabbitConnection = Connect(connectionName); var connection = new SimpleConnection(rabbitConnection, CloseTimeout, _logger); _logger?.LogInformation("Created new connection: " + connectionName + "/" + connection); if (rabbitConnection != null && RecoveryListener != null) { rabbitConnection.RecoverySucceeded += RecoveryListener.HandleRecoverySucceeded; rabbitConnection.ConnectionRecoveryError += RecoveryListener.HandleConnectionRecoveryError; } if (rabbitConnection != null && BlockedListener != null) { rabbitConnection.ConnectionBlocked += BlockedListener.HandleBlocked; rabbitConnection.ConnectionUnblocked += BlockedListener.HandleUnblocked; } return(connection); } catch (Exception e) when(e is IOException || e is TimeoutException) { throw RabbitExceptionTranslator.ConvertRabbitAccessException(e); } }
protected virtual IConnection CreateBareConnection() { try { var connectionName = ObtainNewConnectionName(); var rabbitConnection = Connect(connectionName); var connection = new SimpleConnection(rabbitConnection, CloseTimeout, _loggerFactory?.CreateLogger <SimpleConnection>()); _logger?.LogInformation("Created new connection: {connectionName}/{connection}", connectionName, connection); if (rabbitConnection != null && RecoveryListener != null) { rabbitConnection.RecoverySucceeded += RecoveryListener.HandleRecoverySucceeded; rabbitConnection.ConnectionRecoveryError += RecoveryListener.HandleConnectionRecoveryError; } if (rabbitConnection != null && BlockedListener != null) { rabbitConnection.ConnectionBlocked += BlockedListener.HandleBlocked; rabbitConnection.ConnectionUnblocked += BlockedListener.HandleUnblocked; } if (rabbitConnection != null) { rabbitConnection.ConnectionShutdown += ConnectionShutdownCompleted; } return(connection); } catch (Exception e) { throw RabbitExceptionTranslator.ConvertRabbitAccessException(e); } }