-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Hi,
I'm using version 2.2.9.RELEASE.
Issue:
When an exception occur in a custom recoverer for DefaultAfterRollbackProcessor, the transaction seems to not be rolled back and thus the offset is commit.
Reproduction:
Use transactional kafka listener which throws an exception.
Use DefaultAfterRollbackProcessor with a customer recoverer as follow :
((consumerRecord, e) -> { throw new RuntimeException("Error in recover"); });
AfterRollbackProcessor:
@Bean
public AfterRollbackProcessor<?, ?> afterRollbackProcessor(KafkaTemplate<Object, Object> template, BiConsumer<ConsumerRecord<?, ?>, Exception> recoverer) {
// Send to DLQ on multiple errors
DefaultAfterRollbackProcessor defaultRollbackProcessor = new DefaultAfterRollbackProcessor(recoverer, 1);
// Commit offset when error has been rollback and recovered to a DLQ
defaultRollbackProcessor.setProcessInTransaction(true);
defaultRollbackProcessor.setKafkaTemplate(template);
return defaultRollbackProcessor;
}
The record is not reprocessed even with a restart (without any new messages after the error)
Logs:
2019-10-03 16:39:42.683 ERROR 20993 --- [ntainer#3-0-C-1] essageListenerContainer$ListenerConsumer : Transaction rolled back
2019-10-03 16:39:42.686 ERROR 20993 --- [ntainer#3-0-C-1] o.s.k.l.DefaultAfterRollbackProcessor : Recoverer threw exception
java.lang.RuntimeException: Error in recover