public void When_requeing_a_failed_message()
        {
            //Need to receive to subscribe to feed, before we send a message. This returns an empty message we discard
            _messageConsumer.Receive(1000);

            //Send a sequence of messages, we want to check that ordering is preserved
            _messageProducer.Send(_messageOne);
            _messageProducer.Send(_messageTwo);

            //Now receive, the first message
            var sentMessageOne = _messageConsumer.Receive(30000);

            //now requeue the first message
            _messageConsumer.Requeue(_messageOne, 300);

            //try receiving again; messageTwo should come first
            var sentMessageTwo = _messageConsumer.Receive(30000);
            var messageBodyTwo = sentMessageTwo.Body.Value;

            _messageConsumer.Acknowledge(sentMessageTwo);

            sentMessageOne = _messageConsumer.Receive(3000);
            var messageBodyOne = sentMessageOne.Body.Value;

            _messageConsumer.Acknowledge(sentMessageOne);


            //_should_send_a_message_via_restms_with_the_matching_body
            messageBodyOne.Should().Be(_messageOne.Body.Value);
            messageBodyTwo.Should().Be(_messageTwo.Body.Value);
        }
Beispiel #2
0
        public void When_requeing_a_failed_message_with_delay()
        {
            //clear the queue, and ensure it exists
            _messageConsumer.Receive(1000);

            //send & receive a message
            _messageProducer.Send(_messageOne);
            var message = _messageConsumer.Receive(3000);

            message.Header.HandledCount.Should().Be(0);
            message.Header.DelayedMilliseconds.Should().Be(0);

            //now requeue with a delay
            _messageConsumer.Requeue(_messageOne, 1000);

            //receive and assert
            message = _messageConsumer.Receive(3000);
            message.Header.HandledCount.Should().Be(1);
            message.Header.DelayedMilliseconds.Should().Be(1000);
        }