Esempio n. 1
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);
        }
        public void Move_Endpoint_MovePolicyCreated()
        {
            var builder  = new ErrorPolicyBuilder();
            var endpoint = TestProducerEndpoint.GetDefault();

            builder.Move(endpoint);
            var policy = builder.Build();

            policy.Should().BeOfType <MoveMessageErrorPolicy>();
            policy.As <MoveMessageErrorPolicy>().Endpoint.Should().BeSameAs(endpoint);
        }
        public void Move_EndpointWithConfiguration_SkipPolicyCreatedAndConfigurationApplied()
        {
            var builder  = new ErrorPolicyBuilder();
            var endpoint = TestProducerEndpoint.GetDefault();

            builder.Move(endpoint, movePolicy => movePolicy.MaxFailedAttempts(42));
            var policy = builder.Build();

            policy.Should().BeOfType <MoveMessageErrorPolicy>();
            policy.As <MoveMessageErrorPolicy>().Endpoint.Should().BeSameAs(endpoint);
            policy.As <MoveMessageErrorPolicy>().MaxFailedAttemptsCount.Should().Be(42);
        }
        public void HandleError_InboundMessage_MessageMoved()
        {
            var policy = _errorPolicyBuilder.Move(TestEndpoint.Default);

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

            var producer = (TestProducer)_broker.GetProducer(TestEndpoint.Default);

            producer.ProducedMessages.Count.Should().Be(1);
        }
Esempio n. 5
0
        public void HandleError_InboundMessage_MessageMoved()
        {
            var policy  = _errorPolicyBuilder.Move(TestEndpoint.GetDefault());
            var message = new InboundMessage(
                new byte[1],
                null,
                null, TestEndpoint.GetDefault(), true)
            {
                Content = "hey oh!"
            };

            policy.HandleError(new[]
            {
                message
            }, new Exception("test"));
            var producer = (TestProducer)_broker.GetProducer(TestEndpoint.GetDefault());

            producer.ProducedMessages.Count.Should().Be(1);
        }