/// <summary>Anies the given request.</summary> /// /// <exception cref="UnRetryableMessagingException">Thrown when an Un Retryable Messaging error condition occurs.</exception> /// /// <param name="request">The request.</param> /// /// <returns>An object.</returns> 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>(service.ExecuteAsync); 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)); } } }