'DefaultErrorHandler doesn't log not retryable exceptions
Not retryable exceptions are not logged in DefaultErrorHandler when used with DeadLetterPublishingRecoverer.
@Bean
public CommonErrorHandler consumerErrorHandler(KafkaTemplate<String, KafkaMessage> kafkaTemplate) {
var errorHandler = new DefaultErrorHandler(new DeadLetterPublishingRecoverer(kafkaTemplate), kafkaConsumerRetryProperties.getBackoffPolicy());
errorHandler.addNotRetryableExceptions(NullPointerException.class);
return errorHandler;
}
In this case NullPointerException is not logged whatsoever when thrown in method annotated with @KafkaListener
Solution 1:[1]
Feel free to open an issue on GitHub. In the meantime, you could subclass the DLPR and log the exception in accept() before calling super.accept().
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gary Russell |
