When you’re not a Medium member, you’ll be able to learn the article right here
At some point I acquired a ticket the place I wanted to put in writing a Shopper that will settle for batch messages.
Naturally, as a TDD man, I wrote exams the place I simulated an error whereas the buyer was processing batch messages and anticipated all failed messages to be redirected to the Useless Letter Queue.
Nevertheless, I used to be stunned that not a single message went to the Useless Letter Queue as in regular queue error dealing with instances.
Because it turned out, Spring makes use of RejectAndDontRequeueRecoverer by default, and this object processes just one message at a time, however we have to course of the checklist directly, however how?
After an extended googling 🤪 , on the again of spring docs, I discovered a magic MessageBatchRecoverer 🌚 interface that may assist to handle failed batch messages.
When a batch is being processed directly, retry recoverer helps to deal with errors. If one thing goes flawed, you must embrace the index of the report the place the error occurred within the exception. This manner, the device can correctly deal with the remaining data…