public static ExchangesConfiguration FromCode(params Exchange[] exchanges)
        {
            var conf = new ExchangesConfiguration();
            if(exchanges != null && exchanges.Length > 0)
                conf._exchanges.AddRange(exchanges);

            return conf;
        }
Пример #2
0
        public Rabbit DeclareExchanges(ExchangesConfiguration exchangesConfiguration)
        {
            if (Log.IsInfoEnabled)
                Log.Info("Declaring Exchanges...");

            var channel = ComponentLocator.Current.Get<IModel>();

            foreach (var exchange in exchangesConfiguration.Exchanges)
            {
                if (Log.IsDebugEnabled)
                    Log.Debug("Declaring Exchange: {0}, of type: {1}, durable: {2}", exchange.Name, exchange.Type, exchange.Durable);

                channel.ExchangeDeclare(exchange.Name, exchange.Type, exchange.Durable);
            }

            if (Log.IsInfoEnabled)
                Log.Info("Exchanges declared.");

            return this;
        }
        public static ExchangesConfiguration FromConfiguration()
        {
            var section = ConfigurationManager.GetSection("ExchangesConfigurationSection") as ExchangeConfigurationSection;
            if(section == null)
                return new ExchangesConfiguration();

            var conf = new ExchangesConfiguration();

            foreach (ExchangeElement exchange in section.Exchanges)
            {
                conf._exchanges.Add(new Exchange
                                        {
                                            Durable = exchange.Durable,
                                            Name = exchange.ExchangeName,
                                            Type = exchange.ExchangeType
                                        });
            }

            return conf;
        }