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); }); }
private static OutMessage CreateOutMessageRefStoredAS4Message(AS4Component as4Msh) { string ebmsMessageId = $"receipt-{Guid.NewGuid()}"; var store = new AS4MessageBodyFileStore(); return(new OutMessage(ebmsMessageId) { ContentType = Constants.ContentTypes.Soap, MessageLocation = store.SaveAS4Message( as4Msh.GetConfiguration().InMessageStoreLocation, AS4Message.Create( new Receipt( ebmsMessageId, $"reftoid-{Guid.NewGuid()}"))) }); }