public void AlwaysFailsService_ends_up_in_dlq_after_3_attempts() { var service = Container.Resolve<AlwaysFailService>(); var request = new AlwaysFail { Name = "World!" }; using (var serviceHost = CreateMessagingService()) { using (var client = serviceHost.MessageFactory.CreateMessageQueueClient()) { client.Publish(request); } serviceHost.RegisterHandler<AlwaysFail>(m => service.Any(m.GetBody())); serviceHost.Start(); Assert.That(service.Result, Is.Null); Assert.That(service.TimesCalled, Is.EqualTo(3)); using (var client = serviceHost.MessageFactory.CreateMessageQueueClient()) { var dlqMessage = client.GetAsync<AlwaysFail>(QueueNames<AlwaysFail>.Dlq); client.Ack(dlqMessage); Assert.That(dlqMessage, Is.Not.Null); Assert.That(dlqMessage.GetBody().Name, Is.EqualTo(request.Name)); } } }
public object Any(AlwaysFail request) { this.TimesCalled++; throw new NotSupportedException("This service always fails"); }