Конфигуратор клиента шины сообщений, использующий настройки объявленные в стандартном .config-файле.
Inheritance: IConfigurator
Example #1
0
            public void ShoudUseFaultQueueLimitDefaultIfNotSpecified()
            {
                string producerConfig = string.Format(
                    @"<endpoints>
                            <endpoint name=""producer"" connectionString=""{0}"">
                            </endpoint>
                        </endpoints>", this.AmqpConnection + this.VhostName);

                var section = new XmlEndpointsSection(producerConfig);
                var sut = new AppConfigConfigurator(section, (name, type) => null);

                IBus bus = this.CreateBus(() => new BusFactory().Create(cfg => sut.Configure("producer", cfg), true));
                bus.WhenReady.WaitOne();

                Testing.Plumbing.Queue queue = this.Broker.GetQueues(this.VhostName).First(q => q.Name == "producer.Fault");
                CollectionAssert.IsNotEmpty(queue.Arguments, "У очереди producer.Fault должны быть выставлены свойства.");
                Assert.IsFalse(queue.Arguments.ContainsKey("x-max-length"), "У очереди producer.Fault не должно быть установлено ограничение на количество сообщений в очереди.");
            }
Example #2
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        private static void Main(string[] args)
        {
            LogManager.Adapter = new ConsoleOutLoggerFactoryAdapter();

            // super bad resolver
            DependencyResolverFunc dependencyResolver = (name, type) => new SomeHandler();

            var configurator = new AppConfigConfigurator(dependencyResolver);
            var busFactory = new BusFactory();

            IBus consumer = busFactory.Create(cfg => configurator.Configure("Consumer", cfg));
            IBus producer = busFactory.Create(cfg => configurator.Configure("Producer", cfg));

            using (new Timer(_ => producer.Emit(":msg", new { }), null, 0, 1000))
            {
                Console.ReadKey(false);
            }

            producer.Dispose();
            consumer.Dispose();
        }
Example #3
0
            public void ShoudUseFaultQueueTtlDefaultIfNotSpecified()
            {
                string producerConfig = string.Format(
                    @"<endpoints>
                            <endpoint name=""producer"" connectionString=""{0}"">
                            </endpoint>
                        </endpoints>", this.AmqpConnection + this.VhostName);

                var section = new XmlEndpointsSection(producerConfig);
                var sut = new AppConfigConfigurator(section, (name, type) => null);

                IBus bus = this.CreateBus(() => new BusFactory().Create(cfg => sut.Configure("producer", cfg), true));
                bus.WhenReady.WaitOne();

                Testing.Plumbing.Queue queue = this.Broker.GetQueues(this.VhostName).First(q => q.Name == "producer.Fault");
                CollectionAssert.IsNotEmpty(queue.Arguments, "У очереди producer.Fault должны быть выставлены свойства.");
                Assert.IsTrue(queue.Arguments.ContainsKey("x-message-ttl"), "У очереди producer.Fault должно быть установлено время жизни.");
                Assert.AreEqual((21 * 24 * 60 * 60 * 1000).ToString(), queue.Arguments["x-message-ttl"], "Должно быть установлено время жизни по умолчанию.");
            }