예제 #1
0
        public void HandleError_RetryWithMaxFailedAttempts_AppliedAccordingToMaxFailedAttempts(int failedAttempts)
        {
            var testPolicy = new TestErrorPolicy();

            var chain = _errorPolicyBuilder.Chain(
                _errorPolicyBuilder.Retry().MaxFailedAttempts(3),
                testPolicy);

            chain.HandleError(new InboundMessage {
                Message = new TestEventOne(), FailedAttempts = failedAttempts
            }, new Exception("test"));

            testPolicy.Applied.Should().Be(failedAttempts > 3);
        }
예제 #2
0
        public async Task Bind_WithChainedErrorPolicy_RetriedAndMoved()
        {
            _testSubscriber.MustFailCount = 3;
            _connector.Bind(TestEndpoint.GetDefault(), _errorPolicyBuilder.Chain(
                                _errorPolicyBuilder.Retry().MaxFailedAttempts(1),
                                _errorPolicyBuilder.Move(new TestEndpoint("bad"))));
            _broker.Connect();

            var consumer = _broker.Consumers.First();
            await consumer.TestPush(new TestEventOne { Content = "Test", Id = Guid.NewGuid() });

            var producer = (TestProducer)_broker.GetProducer(new TestEndpoint("bad"));

            _testSubscriber.FailCount.Should().Be(2);
            _testSubscriber.ReceivedMessages.Count.Should().Be(2);
            producer.ProducedMessages.Count.Should().Be(1);
        }
예제 #3
0
        public void HandleError_RetryWithMaxFailedAttempts_AppliedAccordingToMaxFailedAttempts(int failedAttempts)
        {
            var testPolicy = new TestErrorPolicy();

            var chain = _errorPolicyBuilder.Chain(
                _errorPolicyBuilder.Retry().MaxFailedAttempts(3),
                testPolicy);

            chain.HandleError(new[]
            {
                new InboundMessage(
                    new byte[1],
                    new[] { new MessageHeader(MessageHeader.FailedAttemptsKey, failedAttempts.ToString()) },
                    null, TestEndpoint.GetDefault(), true)
            }, new Exception("test"));

            testPolicy.Applied.Should().Be(failedAttempts > 3);
        }