public void LogProcessingFatalError_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 = "Fatal error occurred processing the consumed message. The consumer will be stopped. | " + "endpointName: test1, " + "messageType: Message.Type, " + "messageId: 1234, " + "unused1: (null), " + "unused2: (null)"; _inboundLogger.LogProcessingFatalError(envelope, new ArithmeticException()); _loggerSubstitute.Received(LogLevel.Critical, typeof(ArithmeticException), expectedMessage, 1023); }
public void LogProcessingFatalError_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 = "Fatal error occurred processing the consumed message. The consumer will be stopped. | " + "endpointName: topic2, " + "messageType: Message.Type, " + "messageId: 1234, " + "offset: [2]@42, " + "kafkaKey: key1234"; _inboundLogger.LogProcessingFatalError(envelope, new ArithmeticException()); _loggerSubstitute.Received(LogLevel.Critical, typeof(ArithmeticException), expectedMessage, 1023); }
/// <inheritdoc cref="IConsumerBehavior.HandleAsync" /> public async Task HandleAsync( ConsumerPipelineContext context, ConsumerBehaviorHandler next) { Check.NotNull(context, nameof(context)); Check.NotNull(next, nameof(next)); try { await next(context).ConfigureAwait(false); } catch (Exception ex) { _logger.LogProcessingFatalError(context.Envelope, ex); throw new ConsumerPipelineFatalException( "Fatal error occurred processing the consumed message.", ex); } }