public MessagePumpRetryCommandOnConnectionFailureTests()
        {
            _commandProcessor = new SpyCommandProcessor();
            var channel = new FailingChannel {
                NumberOfRetries = 1
            };
            var mapper = new MyCommandMessageMapper();

            _messagePump = new MessagePump <MyCommand>(_commandProcessor, mapper)
            {
                Channel = channel, TimeoutInMilliseconds = 500, RequeueCount = -1
            };

            var command = new MyCommand();

            //two command, will be received when connection restored
            var message1 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_COMMAND), new MessageBody(JsonConvert.SerializeObject(command)));
            var message2 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_COMMAND), new MessageBody(JsonConvert.SerializeObject(command)));

            channel.Enqueue(message1);
            channel.Enqueue(message2);

            //end the pump
            var quitMessage = new Message(new MessageHeader(Guid.Empty, "", MessageType.MT_QUIT), new MessageBody(""));

            channel.Enqueue(quitMessage);
        }
        public MessagePumpRetryEventConnectionFailureTests()
        {
            _commandProcessor = new SpyCommandProcessor();
            var channel = new FailingChannel {
                NumberOfRetries = 1
            };
            var mapper = new MyEventMessageMapper();

            _messagePump = new MessagePump <MyEvent>(_commandProcessor, mapper)
            {
                Channel = channel, TimeoutInMilliseconds = 500, RequeueCount = -1
            };

            var @event = new MyEvent();

            //Two events will be received when channel fixed
            var message1 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_EVENT), new MessageBody(JsonConvert.SerializeObject(@event)));
            var message2 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_EVENT), new MessageBody(JsonConvert.SerializeObject(@event)));

            channel.Enqueue(message1);
            channel.Enqueue(message2);

            //Quit the message pump
            var quitMessage = new Message(new MessageHeader(Guid.Empty, "", MessageType.MT_QUIT), new MessageBody(""));

            channel.Enqueue(quitMessage);
        }
コード例 #3
0
        public void Establish()
        {
            _commandProcessor = new SpyCommandProcessor();
            _channel          = new FailingChannel {
                NumberOfRetries = 4
            };
            var mapper = new MyCommandMessageMapper();

            _messagePump = new MessagePump <MyCommand>(_commandProcessor, mapper)
            {
                Channel = _channel, TimeoutInMilliseconds = 5000, RequeueCount = -1
            };

            _command = new MyCommand();

            var message1 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_COMMAND), new MessageBody(JsonConvert.SerializeObject(_command)));
            var message2 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_COMMAND), new MessageBody(JsonConvert.SerializeObject(_command)));

            _channel.Add(message1);
            _channel.Add(message2);
            var quitMessage = new Message(new MessageHeader(Guid.Empty, "", MessageType.MT_QUIT), new MessageBody(""));

            _channel.Add(quitMessage);
        }
コード例 #4
0
        public MessagePumpRetryEventConnectionFailureTests()
        {
            _commandProcessor = new SpyCommandProcessor();
            _channel          = new FailingChannel {
                NumberOfRetries = 4
            };
            var mapper = new MyEventMessageMapper();

            _messagePump = new MessagePump <MyEvent>(_commandProcessor, mapper)
            {
                Channel = _channel, TimeoutInMilliseconds = 5000, RequeueCount = -1
            };

            _event = new MyEvent();

            var message1 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_EVENT), new MessageBody(JsonConvert.SerializeObject(_event)));
            var message2 = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_EVENT), new MessageBody(JsonConvert.SerializeObject(_event)));

            _channel.Add(message1);
            _channel.Add(message2);
            var quitMessage = new Message(new MessageHeader(Guid.Empty, "", MessageType.MT_QUIT), new MessageBody(""));

            _channel.Add(quitMessage);
        }