public object Any(UnRetryableFail request) { this.TimesCalled++; throw new UnRetryableMessagingException( "This request should not get retried", new NotSupportedException("This service always fails")); }
public void UnRetryableFailService_ends_up_in_dlq_after_1_attempt() { var service = Container.Resolve<UnRetryableFailService>(); var request = new UnRetryableFail { Name = "World!" }; using (var serviceHost = CreateMessagingService()) { using (var client = serviceHost.MessageFactory.CreateMessageQueueClient()) { client.Publish(request); } serviceHost.RegisterHandler<UnRetryableFail>(m => service.Any(m.GetBody())); serviceHost.Start(); Assert.That(service.Result, Is.Null); Assert.That(service.TimesCalled, Is.EqualTo(1)); using (var client = serviceHost.MessageFactory.CreateMessageQueueClient()) { var dlqMessage = client.GetAsync(QueueNames<UnRetryableFail>.Dlq) .ToMessage<UnRetryableFail>(); Assert.That(dlqMessage, Is.Not.Null); Assert.That(dlqMessage.GetBody().Name, Is.EqualTo(request.Name)); } } }