Пример #1
0
        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);
        }
Пример #2
0
        // 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
            });
        }
Пример #3
0
        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;
            }
        }
Пример #4
0
        private int GetNumberQueueConsumers(MessageConsumer messageConsumer)
        {
            BrokerConnectionSettings conn = _brokerState.BrokerSettings.GetConnection(messageConsumer.BrokerName);

            return(conn.GetQueueProperties(messageConsumer.QueueName).NumberConsumers);
        }
Пример #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="settings">The configured broker connection settings.</param>
 public BrokerConnection(BrokerConnectionSettings settings)
 {
     Settings = settings;
 }