public void LogSkipped_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 skipped. | " + "endpointName: test1, " + "messageType: Message.Type, " + "messageId: 1234, " + "unused1: (null), " + "unused2: (null)"; _inboundLogger.LogSkipped(envelope); _loggerSubstitute.Received(LogLevel.Information, null, expectedMessage, 1049); }
public void LogSkipped_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 skipped. | " + "endpointName: topic2, " + "messageType: Message.Type, " + "messageId: 1234, " + "offset: [2]@42, " + "kafkaKey: key1234"; _inboundLogger.LogSkipped(envelope); _loggerSubstitute.Received(LogLevel.Information, null, expectedMessage, 1049); }
protected override async Task <bool> ApplyPolicyAsync( ConsumerPipelineContext context, Exception exception) { Check.NotNull(context, nameof(context)); Check.NotNull(exception, nameof(exception)); _logger.LogSkipped(context.Envelope); if (!await TryRollbackAsync(context, exception).ConfigureAwait(false)) { await context.Consumer.TriggerReconnectAsync().ConfigureAwait(false); } return(true); }