Exemplo n.º 1
0
        public void LogRetryProcessing_Logged()
        {
            var envelope = new RawInboundEnvelope(
                Stream.Null,
                new MessageHeaderCollection
            {
                { DefaultMessageHeaders.MessageType, "Message.Type" },
                { DefaultMessageHeaders.MessageId, "1234" }
            },
                new TestConsumerEndpoint("test1, test2"),
                "test1",
                new TestOffset("a", "42"));

            var expectedMessage =
                "The message(s) will be processed again. | " +
                "endpointName: test1, " +
                "messageType: Message.Type, " +
                "messageId: 1234, " +
                "unused1: (null), " +
                "unused2: (null)";

            _inboundLogger.LogRetryProcessing(envelope);

            _loggerSubstitute.Received(LogLevel.Information, null, expectedMessage, 1046);
        }
Exemplo n.º 2
0
        public void LogRetryProcessing_Logged()
        {
            var envelope = new RawInboundEnvelope(
                Stream.Null,
                new MessageHeaderCollection
            {
                { DefaultMessageHeaders.MessageType, "Message.Type" },
                { DefaultMessageHeaders.MessageId, "1234" },
                { KafkaMessageHeaders.KafkaMessageKey, "key1234" }
            },
                new KafkaConsumerEndpoint("topic1", "topic2"),
                "topic2",
                new KafkaOffset("topic2", 2, 42));

            var expectedMessage =
                "The message(s) will be processed again. | " +
                "endpointName: topic2, " +
                "messageType: Message.Type, " +
                "messageId: 1234, " +
                "offset: [2]@42, " +
                "kafkaKey: key1234";

            _inboundLogger.LogRetryProcessing(envelope);

            _loggerSubstitute.Received(LogLevel.Information, null, expectedMessage, 1046);
        }
Exemplo n.º 3
0
            protected override async Task <bool> ApplyPolicyAsync(
                ConsumerPipelineContext context,
                Exception exception)
            {
                Check.NotNull(context, nameof(context));
                Check.NotNull(exception, nameof(exception));

                if (!await TryRollbackAsync(context, exception).ConfigureAwait(false))
                {
                    await context.Consumer.TriggerReconnectAsync().ConfigureAwait(false);

                    return(true);
                }

                await ApplyDelayAsync(context).ConfigureAwait(false);

                _logger.LogRetryProcessing(context.Envelope);

                return(true);
            }