private IDictionary <string, object> AppendConnectionProperties( BrokerConnectionSettings brokerSettings, IDictionary <string, object> clientProperties) { var props = new Dictionary <string, object>(clientProperties); props["Broker Name"] = brokerSettings.BrokerName; props["Broker User"] = brokerSettings.UserName; props["Time Connected"] = DateTime.Now.ToString(); return(props); }
// Creates a connection factory with an associated list of key/value pairs // that will be associated with the connection. These values can be viewed // within the RabbitMQ Web Administration interface. private IConnectionFactory CreateConnFactory(BrokerConnectionSettings brokerSettings) { IDictionary <string, object> clientProps = AppendConnectionProperties( brokerSettings, _clientProperties); return(new ConnectionFactory { HostName = brokerSettings.HostName, UserName = brokerSettings.UserName, Password = brokerSettings.Password, VirtualHost = brokerSettings.VHostName, ClientProperties = clientProps }); }
private void LogConnectionException(BrokerConnectionSettings settings, int retryCount = 0, BrokerUnreachableException connEx = null) { var connInfo = new { settings.BrokerName, settings.HostName, settings.UserName }; if (retryCount > 0) { _logger.LogErrorDetails(RabbitMqLogEvents.BROKER_EXCEPTION, "Error connecting to broker. Attempt: {attempt}", connInfo, retryCount); } if (connEx != null) { _logger.LogErrorDetails(RabbitMqLogEvents.BROKER_EXCEPTION, connEx, "Error connecting to broker.", connInfo); throw connEx; } }
private int GetNumberQueueConsumers(MessageConsumer messageConsumer) { BrokerConnectionSettings conn = _brokerState.BrokerSettings.GetConnection(messageConsumer.BrokerName); return(conn.GetQueueProperties(messageConsumer.QueueName).NumberConsumers); }
/// <summary> /// Constructor. /// </summary> /// <param name="settings">The configured broker connection settings.</param> public BrokerConnection(BrokerConnectionSettings settings) { Settings = settings; }