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));
            }
        }
Example #2
0
 public void Remove(RabbitMqExchangeElement exchangeElement)
 {
     if (BaseGet(exchangeElement.Name) == null)
     {
         BaseRemove(exchangeElement.Name);
     }
 }
        public RabbitMqConnector(RabbitMqExchangeElement exchangeConfiguration, RabbitMqQueueElement queueConfiguration, RabbitMqQueuePath queuePath)
        {
            _exchangeConfiguration = exchangeConfiguration;
            QueueConfiguration     = queueConfiguration;
            QueuePath = queuePath;

            var port = QueuePath.ConnnectUri.Port < 1
                                ? AmqpTcpEndpoint.UseDefaultPort
                                : QueuePath.ConnnectUri.Port;

            var factory = new ConnectionFactory()
            {
                uri = QueuePath.ConnnectUri, Port = port
            };

            _connection = factory.CreateConnection();
        }
Example #4
0
 public void Add(RabbitMqExchangeElement exchangeElement)
 {
     BaseAdd(exchangeElement);
 }