Record recovery in transactional batch listener #3332
Replies: 2 comments 2 replies
-
|
@tommyk-gears Can you refine your exact use case? The way I understand the issue is that you have a transactional batch listener and want to recover failing records. Is that the right assumption? By default, you can only recover the entire batch. Upon failure of a record, the entire batch will be redelivered. We made some recent improvements in this area. Can you take a look at this issue and the associated PR to see if the improvements mentioned here give you any pointers? I am not suggesting that these are the solutions for your issue, but I want to start with these recent changes and see if we can get to a point where we can isolate the exact use case at hand. Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
Hello, i have the same problem, any help please. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to implement/configure error handling for Kafka listeners with two relatively straight forward basic requirements;
I'd assume those are quite common/universal requirements.
For now I'm assuming that any batch listener will throw
BatchListenerFailedExceptionto indicate which record failed.I have four different cases that I want to support;
Now, I managed to get the two first cases working by using a
CommonErrorHandlerwhich sends failing records to a record recoverer, and the third case also works by usingDefaultAfterRollbackProcessorwhich sends the failing record to a record recoverer.However, the fourth case seems a whole lot harder. As I understand it the batch is "atomic" when it comes to recovery, either you recover all records in a failing batch, or you redeliver the complete batch. I tried using a method interceptor along the lines of this comment: #2233 (comment), which lets me retry partial batches - but I fail to figure out how to commit offsets for successfully retried partial batches. The offset commit logics is very much in the hands of the
ListenerContainer, which leads me to believe that the retry logics also needs to be inside theListenerContainer. The logics I'd like to have here is basically;BatchListenerFailedExceptionand get the index of the failing record.Now we can have a
AfterRollbackProcessorthat will recover and commit recovered batches only if the batch contains a single record.Does this make sense? Or is there a way to have this functionality with existing abstractions (I considered using a BatchMessageListener adapter, but I don't see a way forward with it)?
Also, it is mentioned in the documentation that "Default behavior, recovery is not possible with a batch listener, since the framework has no knowledge about which record in the batch keeps failing". Is this really true? There is nothing stopping a transactional batch listener from using
BatchListenerFailedExceptionto find out which record failed as far as I understand.Beta Was this translation helpful? Give feedback.
All reactions