Exemplo n.º 1
0
        public void InitializeBus()
        {
            consumerContainer = new SimpleConsumerContainer();

            Bus = new RogerBus(ConnectionFactory,
                               consumerContainer,
                               idGenerator: IdGenerator,
                               sequenceGenerator: SequenceGenerator,
                               options: new RogerOptions(prefetchCount: null /*no safety nets during tests*/));

            Bus.Filters.Add(MessageFilters.ToArray());

            localConnection = Helpers.CreateConnection();
            TestModel       = localConnection.CreateModel();
            TestModel.ExchangeDeclare("TestExchange",
                                      ExchangeType.Topic,
                                      true /* to have the exchange there when restarting broker app within tests */,
                                      false,
                                      null);

            BeforeBusInitialization();

            Bus.Start();

            AfterBusInitialization();
        }
Exemplo n.º 2
0
        public void Start_should_be_idempotent_on_an_already_started_bus()
        {
            var connectionFactory = Substitute.For<IConnectionFactory>();
            var connection = Substitute.For<IConnection>();
            connectionFactory.CreateConnection().Returns(connection);
            var model = Substitute.For<IModel>();
            connection.CreateModel().Returns(model);
            model.QueueDeclare("", false, false, false, null).ReturnsForAnyArgs(new QueueDeclareOk("", 0, 0));

            var bus = new RogerBus(connectionFactory);

            bus.Start();
            bus.Start();

            connectionFactory.Received(1).CreateConnection();

            bus.Dispose();
        }
Exemplo n.º 3
0
        public void Start(WaitHandle waitHandle)
        {
            var connectionFactory = new DefaultConnectionFactory(Constants.HostName);

            PublisherConfirmsProvider.DeclareExchange(connectionFactory);

            var bus = new RogerBus(connectionFactory);
            bus.Start();
            StartPublishing(bus, waitHandle);
        }
Exemplo n.º 4
0
        public void Start_should_be_idempotent_on_an_already_started_bus()
        {
            var connectionFactory = Substitute.For <IConnectionFactory>();
            var connection        = Substitute.For <IConnection>();

            connectionFactory.CreateConnection().Returns(connection);
            var model = Substitute.For <IModel>();

            connection.CreateModel().Returns(model);
            model.QueueDeclare("", false, false, false, null).ReturnsForAnyArgs(new QueueDeclareOk("", 0, 0));

            var bus = new RogerBus(connectionFactory);

            bus.Start();
            bus.Start();

            connectionFactory.Received(1).CreateConnection();

            bus.Dispose();
        }
Exemplo n.º 5
0
        public void Start(WaitHandle waitHandle)
        {
            var connectionFactory = new DefaultConnectionFactory(Constants.HostName);

            PublisherConfirmsProvider.DeclareExchange(connectionFactory);

            var bus = new RogerBus(connectionFactory);

            bus.Start();
            StartPublishing(bus, waitHandle);
        }
Exemplo n.º 6
0
        public void Start(WaitHandle waitHandle)
        {
            var connectionFactory = new DefaultConnectionFactory(Constants.HostName);

            PublisherConfirmsProvider.DeclareExchange(connectionFactory);
            var bus = new RogerBus(connectionFactory, new SimpleConsumerContainer(new PublisherConfirmsConsumer()));
            bus.Start();

            waitHandle.WaitOne();

            bus.Dispose();
        }
Exemplo n.º 7
0
        protected override void AfterBusInitialization()
        {
            secondaryConsumerContainer = new SimpleConsumerContainer();

            BeforeSecondaryBusInitialization();

            SecondaryBus = new RogerBus(new ManualConnectionFactory(Helpers.CreateConnectionOnAlternativePort),
                                        secondaryConsumerContainer, options: new RogerOptions(prefetchCount: null));

            SecondaryBus.Start();

            AfterSecondaryBusInitialization();
        }
Exemplo n.º 8
0
        public void Start(WaitHandle waitHandle)
        {
            var connectionFactory = new DefaultConnectionFactory(Constants.HostName);

            PublisherConfirmsProvider.DeclareExchange(connectionFactory);
            var bus = new RogerBus(connectionFactory, new SimpleConsumerContainer(new PublisherConfirmsConsumer()));

            bus.Start();

            waitHandle.WaitOne();

            bus.Dispose();
        }
Exemplo n.º 9
0
        protected override void AfterBusInitialization()
        {
            secondaryConsumerContainer = new SimpleConsumerContainer();

            BeforeSecondaryBusInitialization();

            SecondaryBus = new RogerBus(new ManualConnectionFactory(Helpers.CreateConnectionOnAlternativePort),
                                        secondaryConsumerContainer, options: new RogerOptions(prefetchCount: null));

            SecondaryBus.Start();

            AfterSecondaryBusInitialization();
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            var connectionFactory = new DefaultConnectionFactory("localhost");

            using (var connection = connectionFactory.CreateConnection())
            {
                var model = connection.CreateModel();

                model.ExchangeDeclare("RabbusChat", ExchangeType.Topic, false);
            }

            var consumerContainer = new SimpleConsumerContainer();

            var bus  = new RogerBus(connectionFactory, consumerContainer, exchangeResolver: new StaticExchangeResolver("RabbusChat"));
            var chat = new ChatServer(bus);

            consumerContainer.Register(chat);

            bus.Start();

            Console.ReadLine();

            bus.Dispose();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var connectionFactory = new DefaultConnectionFactory("localhost");

            using(var connection = connectionFactory.CreateConnection())
            {
                var model = connection.CreateModel();

                model.ExchangeDeclare("RabbusChat", ExchangeType.Topic, false);
            }

            var consumerContainer = new SimpleConsumerContainer();

            var bus = new RogerBus(connectionFactory, consumerContainer, exchangeResolver: new StaticExchangeResolver("RabbusChat"));
            var chat = new ChatServer(bus);

            consumerContainer.Register(chat);

            bus.Start();

            Console.ReadLine();

            bus.Dispose();
        }
Exemplo n.º 12
0
        public void InitializeBus()
        {
            consumerContainer = new SimpleConsumerContainer();

            Bus = new RogerBus(ConnectionFactory,
                               consumerContainer,
                               idGenerator: IdGenerator,
                               sequenceGenerator: SequenceGenerator,
                               options: new RogerOptions(prefetchCount: null /*no safety nets during tests*/));

            Bus.Filters.Add(MessageFilters.ToArray());

            localConnection = Helpers.CreateConnection();
            TestModel = localConnection.CreateModel();
            TestModel.ExchangeDeclare("TestExchange",
                                      ExchangeType.Topic,
                                      true /* to have the exchange there when restarting broker app within tests */,
                                      false,
                                      null);

            BeforeBusInitialization();

            Bus.Start();

            AfterBusInitialization();
        }