Пример #1
0
        public void LogMoved_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 will be moved to the endpoint 'target1'. | " +
                "endpointName: test1, " +
                "messageType: Message.Type, " +
                "messageId: 1234, " +
                "unused1: (null), " +
                "unused2: (null)";

            _inboundLogger.LogMoved(envelope, new TestProducerEndpoint("target1"));

            _loggerSubstitute.Received(LogLevel.Information, null, expectedMessage, 1048);
        }
Пример #2
0
        public void LogMoved_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 will be moved to the endpoint 'target1'. | " +
                "endpointName: topic2, " +
                "messageType: Message.Type, " +
                "messageId: 1234, " +
                "offset: [2]@42, " +
                "kafkaKey: key1234";

            _inboundLogger.LogMoved(envelope, new TestProducerEndpoint("target1"));

            _loggerSubstitute.Received(LogLevel.Information, null, expectedMessage, 1048);
        }
Пример #3
0
            protected override async Task <bool> ApplyPolicyAsync(
                ConsumerPipelineContext context,
                Exception exception)
            {
                Check.NotNull(context, nameof(context));
                Check.NotNull(exception, nameof(exception));

                _logger.LogMoved(context.Envelope, _endpoint);

                await PublishToNewEndpointAsync(context.Envelope, exception).ConfigureAwait(false);

                await context.TransactionManager.RollbackAsync(exception, true).ConfigureAwait(false);

                return(true);
            }