예제 #1
0
파일: Consumer.cs 프로젝트: simoneb/Roger
        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();
        }
예제 #2
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();
        }
예제 #3
0
        public void CloseConnection()
        {
            Bus.Dispose();

            AfterBusDispose();

            try
            {
                localConnection.Dispose();
            }
            catch (IOException)
            {
                // if the broker was restarted in tests this connection would be closed and
                // closing it would throw IOException as the socket is closed
            }
        }
예제 #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();
        }
예제 #5
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();
        }
예제 #6
0
파일: Program.cs 프로젝트: simoneb/Roger
        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();
        }
예제 #7
0
파일: Program.cs 프로젝트: simoneb/Roger
        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();
        }
예제 #8
0
 protected override void AfterBusDispose()
 {
     SecondaryBus.Dispose();
 }