private IQueue ConstructQueue(Uri uri) { lock (_padlock) { RabbitMqConnector connector = null; var queuePath = new RabbitMqQueuePath(uri); var queueConfiguration = Configuration.FindQueueConfiguration(uri); if (queueConfiguration == null) { Configuration.DeclareQueue(uri); queueConfiguration = Configuration.FindQueueConfiguration(uri); } if (!_connectors.TryGetValue(uri, out connector)) { RabbitMqExchangeElement exchangeConfiguration = null; if (!string.IsNullOrEmpty(queueConfiguration.Exchange)) { exchangeConfiguration = Configuration.FindExchangeConfiguration(queueConfiguration.Exchange); if (exchangeConfiguration == null) { throw new UndefinedExchangeException(string.Format(RabbitMqResources.UndefinedExchange, queueConfiguration.Exchange)); } } connector = new RabbitMqConnector(exchangeConfiguration, queueConfiguration, queuePath); _connectors.Add(uri, connector); } return(new RabbitMqQueue(connector)); } }
public RabbitMqQueue(RabbitMqConnector connector) { _connector = connector; _localQueueTimeout = ConfigurationItem <int> .ReadSetting("LocalQueueTimeout", 0); _remoteQueueTimeout = ConfigurationItem <int> .ReadSetting("RemoteQueueTimeout", 2000); _log = Log.For(this); IsLocal = connector.QueuePath.Host.Equals(Environment.MachineName, StringComparison.InvariantCultureIgnoreCase); IsTransactional = connector.QueueConfiguration.IsTransactional; Uri = connector.QueuePath.Uri; _timeout = IsLocal ? TimeSpan.FromMilliseconds(_localQueueTimeout.GetValue()) : TimeSpan.FromMilliseconds(_remoteQueueTimeout.GetValue()); }