コード例 #1
0
        public void Stores_Retry_Information_For_ToBePiggyBacked_SignalMessages(bool isEnabled, int maxRetryCount, TimeSpan retryInterval)
        {
            // Arrange
            string userMessageId = $"user-{Guid.NewGuid()}";

            GetDataStoreContext.InsertInMessage(
                new InMessage(userMessageId)
            {
                MEP = MessageExchangePattern.Pull
            });

            var receipt = new Receipt($"receipt-{Guid.NewGuid()}", userMessageId);
            var context = new MessagingContext(
                AS4Message.Create(receipt),
                MessagingContextMode.Receive)
            {
                SendingPMode = new SendingProcessingMode {
                    Id = "shortcut-send-pmode-retrieval"
                },
                ReceivingPMode = new ReceivingProcessingMode
                {
                    ReplyHandling =
                    {
                        ReplyPattern         = ReplyPattern.PiggyBack,
                        PiggyBackReliability = new AS4.Model.PMode.RetryReliability
                        {
                            IsEnabled     = isEnabled,
                            RetryCount    = maxRetryCount,
                            RetryInterval = retryInterval.ToString()
                        }
                    }
                }
            };

            // Act
            ExerciseStoreSignalMessageAsync(context)
            .GetAwaiter()
            .GetResult();

            // Assert
            GetDataStoreContext.AssertOutMessage(
                receipt.MessageId,
                m => GetDataStoreContext.AssertRetryRelatedOutMessage(
                    m.Id,
                    r =>
            {
                Assert.True(
                    isEnabled == (0 == r?.CurrentRetryCount),
                    $"Enabling PiggyBack Reliability should result in 0 = {r?.CurrentRetryCount}");
                Assert.True(
                    isEnabled == (maxRetryCount == r?.MaxRetryCount),
                    $"Enabling PiggyBack Reliability should result in {maxRetryCount} = {r?.MaxRetryCount}");
                Assert.True(
                    isEnabled == (retryInterval == r?.RetryInterval),
                    $"Enabling PiggyBack Reliability should result in {retryInterval} = {r?.RetryInterval}");
            }));
        }
コード例 #2
0
        public async Task Update_RetryReliability_To_Pending_When_Receiver_Is_Offline()
        {
            // Arrange
            string     ebmsMessageId   = $"user-{Guid.NewGuid()}";
            AS4Message tobeSendMessage = AS4Message.Create(new UserMessage(ebmsMessageId));

            var outMessage = new OutMessage(ebmsMessageId);

            GetDataStoreContext.InsertOutMessage(outMessage);
            GetDataStoreContext.InsertRetryReliability(
                RetryReliability.CreateForOutMessage(
                    refToOutMessageId: outMessage.Id,
                    maxRetryCount: 2,
                    retryInterval: TimeSpan.FromSeconds(1),
                    type: RetryType.Send));

            var ctx = new MessagingContext(
                tobeSendMessage,
                new ReceivedEntityMessage(
                    outMessage,
                    tobeSendMessage.ToStream(),
                    tobeSendMessage.ContentType),
                MessagingContextMode.Send)
            {
                SendingPMode = CreateSendPModeWithPushUrl()
            };

            var   sabotageException = new WebException("Remote host not available");
            IStep sut = CreateSendStepWithResponse(
                StubHttpClient.ThatThrows(sabotageException));

            // Act
            StepResult result = await sut.ExecuteAsync(ctx);

            // Assert
            Assert.False(result.Succeeded);
            GetDataStoreContext.AssertRetryRelatedOutMessage(
                outMessage.Id,
                r =>
            {
                Assert.NotNull(r);
                Assert.Equal(RetryStatus.Pending, r.Status);
            });
        }