Description
Affects Version(s): 2.3.1.RELEASE
🎁 Enhancement
Spring kafka should handle some fatal exceptions like InvalidPidMappingException, UnknownProducerIdException.
Context: processing messages with transactions in non batch mode
Problem: Some exceptions like InvalidPidMappingException, UnknownProducerIdException are fatal and will cause KafkaMessageListenerContainer to fail every time polled record is processed
Usecase:
- Records are polled
- Transaction fails because of InvalidPidMappingException or UnknownProducerIdException when processing record
- Rollback processing fails for InvalidPidMappingException or will send message to DLT for UnknownProducerIdException (if configured to do so)
- Next poll will get another record which will have the same problem because exception is fatal
- in case of InvalidPidMappingException records will be processed after service is restarted or the is a rebalance
- in case of UnknownProducerIdException records wont be processed again since offsets were commited in rollback processing
Currently InvalidPidMappingException exception can be handled in ErrorHandler but the only thing I can think of is to restart listener container.
For UnknownProducerIdException it is possible to not perform rollback processing and handle in the same way as InvalidPidMappingException in error handler.
This is strange and it should be handled by spring-kafka since it is a common problem when using transactions.