Пример #1
0
            public void Should_notify_model_and_then_consumer(Expression <Action <IModel> > close)
            {
                var model = connection.CreateModel();

                var consumer = new SpyConsumer(wh, cancel: true, shutdown: true);

                model.BasicConsume(model.QueueDeclare(), false, consumer);

                wh.CaptureMethod <string>(consumer.HandleBasicCancel);
                wh.CaptureMethod <IModel, ShutdownEventArgs>(consumer.HandleModelShutdown);
                model.ModelShutdown += wh.CaptureEvent <ModelShutdownEventHandler>();

                close.Compile().Invoke(model);
            }
Пример #2
0
        public void ManualTest()
        {
            connection.CallbackException += LoggingConnectionCallbackException(1);
            //connection.CallbackException += ThrowingConnectionCallbackException;
            //connection.CallbackException += LoggingConnectionCallbackException(2);
            connection.ConnectionShutdown += LoggingConnectionOnConnectionShutdown(1);
            //connection.ConnectionShutdown += ThrowingConnectionOnConnectionShutdown;
            //connection.ConnectionShutdown += LoggingConnectionOnConnectionShutdown(2);

            var model = connection.CreateModel();

            //model.TxSelect();
            //model.ConfirmSelect();

            model.CallbackException += LoggingModelOnCallbackException(1);
            //model.CallbackException += ThrowingModelOnCallbackException;
            //model.CallbackException += LoggingModelOnCallbackException(2);
            model.ModelShutdown += LoggingModelOnModelShutdown(1);
            //model.ModelShutdown += ThrowingModelOnModelShutdown;
            //model.ModelShutdown += LoggingModelOnModelShutdown(2);

            var consumer = new SpyConsumer();
            var queue    = model.QueueDeclare("", false, true, true, null);

            log.Debug("Invoking basic consume");
            model.BasicConsume(queue, true, consumer);

            log.Debug("Invoking basic publish");
            model.BasicPublish("", queue, null, "Ciao".Bytes());

            Thread.Sleep(2000);

            //model.BasicAck(2, false);

            Thread.Sleep(2000);
            //model.QueueDelete(queue);

            Thread.Sleep(2000);

            //log.Debug("Closing model");
            //model.Close();

            Thread.Sleep(2000);


            log.Debug("Closing connection");
            //connection.Close();
        }
Пример #3
0
        public void ManualTest()
        {
            connection.CallbackException += LoggingConnectionCallbackException(1);
            //connection.CallbackException += ThrowingConnectionCallbackException;
            //connection.CallbackException += LoggingConnectionCallbackException(2);
            connection.ConnectionShutdown += LoggingConnectionOnConnectionShutdown(1);
            //connection.ConnectionShutdown += ThrowingConnectionOnConnectionShutdown;
            //connection.ConnectionShutdown += LoggingConnectionOnConnectionShutdown(2);

            var model = connection.CreateModel();
            //model.TxSelect();
            //model.ConfirmSelect();

            model.CallbackException += LoggingModelOnCallbackException(1);
            //model.CallbackException += ThrowingModelOnCallbackException;
            //model.CallbackException += LoggingModelOnCallbackException(2);
            model.ModelShutdown += LoggingModelOnModelShutdown(1);
            //model.ModelShutdown += ThrowingModelOnModelShutdown;
            //model.ModelShutdown += LoggingModelOnModelShutdown(2);

            var consumer = new SpyConsumer();
            var queue = model.QueueDeclare("", false, true, true, null);

            log.Debug("Invoking basic consume");
            model.BasicConsume(queue, true, consumer);

            log.Debug("Invoking basic publish");
            model.BasicPublish("", queue, null, "Ciao".Bytes());

            Thread.Sleep(2000);

            //model.BasicAck(2, false);

            Thread.Sleep(2000);
            //model.QueueDelete(queue);

            Thread.Sleep(2000);

            //log.Debug("Closing model");
            //model.Close();

            Thread.Sleep(2000);

            log.Debug("Closing connection");
            //connection.Close();
        }
Пример #4
0
            public void Should_notify_model_and_then_consumer(Expression<Action<IModel>> close)
            {
                var model = connection.CreateModel();

                var consumer = new SpyConsumer(wh, cancel: true, shutdown: true);

                model.BasicConsume(model.QueueDeclare(), false, consumer);

                wh.CaptureMethod<string>(consumer.HandleBasicCancel);
                wh.CaptureMethod<IModel, ShutdownEventArgs>(consumer.HandleModelShutdown);
                model.ModelShutdown += wh.CaptureEvent<ModelShutdownEventHandler>();

                close.Compile().Invoke(model);
            }