Пример #1
0
        public void Should_discard_failed_messages_to_when_discard_failures_configured()
        {
            var logger = new FakeLogger();
            var handler = new FakeExceptionThrowingUserHandler();
            var errorQueue = new FakeValidMessageQueue();
            var readQueue = QueueWithTwoMessages();
            var bus = new Bus(new FakeBusConfig { DiscardFailures = true }, logger, errorQueue, readQueue, new[] { new FakeValidMessageQueue() });
            bus.RegisterHandler(handler);

            bus.Receive<FakeDto>();

            Assert.That(errorQueue.Count, Is.EqualTo(0));
            Assert.That(readQueue.Count, Is.EqualTo(0));
        }
Пример #2
0
        public void Should_log_all_steps_involved()
        {
            var logger = new FakeLogger();
            var msg = new FakeDto();
            var writeQueues = new[] { new FakeValidMessageQueue() };
            var bus = new Bus(new FakeBusConfig(), logger, new FakeValidMessageQueue(), new FakeValidMessageQueue(), writeQueues);

            bus.Send(msg);

            Assert.That(logger[0], Is.StringEnding("Transaction started"));
            Assert.That(logger[1], Is.StringEnding("Started SEND Operation"));
            Assert.That(logger[2], Is.StringEnding("Payload: FakeDto"));
            Assert.That(logger[3], Is.StringEnding("Sent to queue: FakeValidMessageQueue"));
            Assert.That(logger[4], Is.StringEnding("Completed SEND Operation"));
            Assert.That(logger[5], Is.StringEnding("Transaction committed"));
        }
Пример #3
0
        public void Should_log_all_steps_involved()
        {
            var logger = new FakeLogger();
            var readQueue = new FakeValidMessageQueue();
            var bus = new Bus(new FakeBusConfig(), logger, QueueWithOneMessage(), readQueue, new[] { new FakeValidMessageQueue() });

            bus.ReturnAllErrorMessages();

            Assert.That(logger[0], Is.StringEnding("Started RETURN_TO_SOURCE Operation"));
            Assert.That(logger[1], Is.StringEnding("Removing from queue: FakeValidMessageQueue"));
            Assert.That(logger[2], Is.StringEnding("Sending to queue: FakeValidMessageQueue"));
            Assert.That(logger[3], Is.StringEnding("Completed RETURN_TO_SOURCE Operation"));
        }
Пример #4
0
        public void Should_move_failed_messages_to_error_queue_when_fail_fast_not_configured()
        {
            var logger = new FakeLogger();
            var handler = new FakeExceptionThrowingUserHandler();
            var errorQueue = new FakeValidMessageQueue();
            var readQueue = QueueWithTwoMessages();
            var bus = new Bus(new FakeBusConfig { FailFast = false }, logger, errorQueue, readQueue, new[] { new FakeValidMessageQueue() });
            bus.RegisterHandler(handler);

            bus.Receive<FakeDto>();

            Assert.That(errorQueue.Count, Is.EqualTo(2));
            Assert.That(readQueue.Count, Is.EqualTo(0));
        }
Пример #5
0
        public void Should_log_retries_on_error()
        {
            var logger = new FakeLogger();
            var handler = new FakeExceptionThrowingUserHandler();
            var errorQueue = new FakeValidMessageQueue();
            var bus = new Bus(new FakeBusConfig { MaxRetries = 2 }, logger, errorQueue, QueueWithOneMessage(), new[] { new FakeValidMessageQueue() });
            bus.RegisterHandler(handler);

            bus.Receive<FakeDto>();

            Assert.That(logger[0], Is.StringEnding("Transaction started"));
            Assert.That(logger[1], Is.StringEnding("Started RECEIVE Operation"));
            Assert.That(logger[2], Is.StringEnding("Payload: FakeDto"));
            Assert.That(logger[3], Is.StringEnding("Invoking registered handler"));
            Assert.That(logger[4], Is.StringEnding("Retry attempt 1"));
            Assert.That(logger[5], Is.StringEnding("Payload: FakeDto"));
            Assert.That(logger[6], Is.StringEnding("Invoking registered handler"));
            Assert.That(logger[7], Is.StringEnding("Retry attempt 2"));
            Assert.That(logger[8], Is.StringEnding("Payload: FakeDto"));
            Assert.That(logger[9], Is.StringEnding("Invoking registered handler"));
            Assert.That(logger[10], Is.StringEnding("Invocation failed"));
            Assert.That(logger[11], Is.StringEnding("Removing from read queue: FakeValidMessageQueue"));
            Assert.That(logger[12], Is.StringEnding("Moving to error queue: FakeValidMessageQueue"));
            Assert.That(logger[13], Is.StringEnding("EXCEPTION The method or operation is not implemented."));
            Assert.That(logger[15], Is.StringEnding("Completed RECEIVE Operation"));
            Assert.That(logger[16], Is.StringEnding("Transaction rolled back"));
        }
Пример #6
0
        public void Should_log_all_steps_involved()
        {
            var logger = new FakeLogger();
            var handler = new FakeEndUserHandler();
            var bus = new Bus(new FakeBusConfig(), logger, new FakeValidMessageQueue(), QueueWithOneMessage(), new[] { new FakeValidMessageQueue() });
            bus.RegisterHandler(handler);

            bus.Receive<FakeDto>();

            Assert.That(logger[0], Is.StringEnding("Transaction started"));
            Assert.That(logger[1], Is.StringEnding("Started RECEIVE Operation"));
            Assert.That(logger[2], Is.StringEnding("Payload: FakeDto"));
            Assert.That(logger[3], Is.StringEnding("Invoking registered handler"));
            Assert.That(logger[4], Is.StringEnding("Removing from read queue: FakeValidMessageQueue"));
            Assert.That(logger[5], Is.StringEnding("Completed RECEIVE Operation"));
            Assert.That(logger[6], Is.StringEnding("Transaction committed"));
        }