public async Task OutMessage_Is_To_Notified_When_Retry_Happen_Withing_Allowed_MaxRetry( HttpStatusCode secondAttemptStatusCode, Operation expected) { await TestComponentWithSettings( "outmessage_notify_reliability_settings.xml", async (settings, as4Msh) => { // Arrange const string url = "http://localhost:7071/business/outmessage/"; string ebmsMessageId = $"error-{Guid.NewGuid()}"; var store = new AS4MessageBodyFileStore(); var om = new OutMessage(ebmsMessageId) { ContentType = Constants.ContentTypes.Soap, MessageLocation = store.SaveAS4Message( as4Msh.GetConfiguration().InMessageStoreLocation, AS4Message.Create( Error.FromErrorResult( ebmsMessageId, refToMessageId: $"user-{Guid.NewGuid()}", result: new ErrorResult( "Invalid header example description failure", ErrorAlias.InvalidHeader)))) }; SendingProcessingMode pmode = NotifySendingPMode(url); Entities.RetryReliability CreateRetry(long id) => Entities.RetryReliability.CreateForOutMessage( refToOutMessageId: id, maxRetryCount: pmode.ErrorHandling.Reliability.RetryCount, retryInterval: pmode.ErrorHandling.Reliability.RetryInterval.AsTimeSpan(), type: RetryType.Notification); // Act InsertMessageEntityWithRetry(om, as4Msh.GetConfiguration(), pmode, CreateRetry); // Assert SimulateNotifyFailureOnFirstAttempt(url, secondAttemptStatusCode); var spy = new DatabaseSpy(as4Msh.GetConfiguration()); OutMessage notified = await PollUntilPresent( () => spy.GetOutMessageFor( m => m.Operation == expected), timeout: TimeSpan.FromSeconds(10)); Assert.Equal(ebmsMessageId, notified.EbmsMessageId); Entities.RetryReliability referenced = await PollUntilPresent( () => spy.GetRetryReliabilityFor(r => r.RefToOutMessageId == notified.Id), timeout: TimeSpan.FromSeconds(5)); Assert.Equal(RetryStatus.Completed, referenced.Status); }); }
public async Task OutException_Is_Set_To_Notified_When_Retry_Happen_Within_Allowed_MaxRetry( HttpStatusCode secondAttempt, Operation expected) { await TestComponentWithSettings( "outexception_notify_reliability_settings.xml", async (settings, as4Msh) => { // Arrange var handler = new OutboundExceptionHandler( () => new DatastoreContext(as4Msh.GetConfiguration()), as4Msh.GetConfiguration(), Registry.Instance.MessageBodyStore); const string url = "http://localhost:7070/business/outexception/"; string ebmsMessageId = $"entity-{Guid.NewGuid()}"; var spy = new DatabaseSpy(as4Msh.GetConfiguration()); //var entity = new OutMessage(ebmsMessageId); //spy.InsertOutMessage(entity); // Act await handler.HandleExecutionException( new Exception("This is an test exception"), new MessagingContext(new SubmitMessage()) { SendingPMode = NotifySendingPMode(url) }); // Arrange SimulateNotifyFailureOnFirstAttempt(url, secondAttempt); OutException notified = await PollUntilPresent( () => spy.GetOutExceptions( ex => ex.Operation == expected).FirstOrDefault(), timeout: TimeSpan.FromSeconds(10)); Entities.RetryReliability referenced = await PollUntilPresent( () => spy.GetRetryReliabilityFor(r => r.RefToOutExceptionId == notified.Id), timeout: TimeSpan.FromSeconds(5)); Assert.Equal(RetryStatus.Completed, referenced.Status); }); }