SpringSpring Kafka Error Handling
How do you handle deserialization errors in Spring Kafka?
Reference answer
Use ErrorHandlingDeserializer2 wrapper. Configure: spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.ErrorHandlingDeserializer and set spring.kafka.consumer.properties.spring.deserializer.value.delegate.class to your actual deserializer. Failed deserializations wrap the error in a DeserializationException and place it in the ConsumerRecord's value — the @KafkaListener receives the exception which can be caught and routed to a DLT by DefaultErrorHandler. Without this, deserialization errors will cause the container to throw and potentially block processing.
Expected key concepts: ErrorHandlingDeserializer, DeserializationException, spring.deserializer.value.delegate.class, DefaultErrorHandler, DLT, blocking, container, deserialization errors