davsclaus commented on PR #27173:
URL: https://github.com/apache/camel/pull/27173#issuecomment-6067598019

   @mionker Good questions.
   
   **Poison batch.** I don't think the batch consumer should build its own 
retry logic. It should follow the single-message sjms consumer, which leaves 
poison messages to the broker:
   
   1. **Report the failure instead of only logging it.** Wire the `else` branch 
in `BatchConsumerWorker.onBatch()` to the consumer's `ExceptionHandler` instead 
of the `LOG.warn(... "This exception is ignored")`. This is the same thing 
gnodet-bot's latest review suggests. That way `bridgeErrorHandler` and custom 
exception handlers apply to batches too. Keep the rollback in `doOnBatch()` as 
it is.
   2. **Leave redelivery limits to the broker.** After the rollback, the broker 
redelivers. How often, and how fast, is the broker's redelivery policy: in 
Artemis that's `max-delivery-attempts` (default 10, then the DLQ) and 
`redelivery-delay` (default 0, which is what makes the loop tight). The 
single-message transacted consumer behaves the same way today, so this is not 
new to batching. Please document it in the batch section of 
`sjms-component.adoc`. Point out that one bad message fails, and redelivers, 
the whole batch, so all of its messages share the delivery count and end up in 
the DLQ together. Also point out that a route can avoid this by handling 
failures per message inside the batch, for example `split(body())` with 
`doTry`, or `onException(...).handled(true)`. The inner exchanges carry 
`JMSRedelivered`, so a route can detect a redelivered batch.
   3. A test with `transacted=true` and a route that always fails, checking 
that the `ExceptionHandler` is called and the messages are redelivered, would 
cover this. A full DLQ round-trip test isn't needed.
   
   **sjms2.** Yes. `Sjms2Endpoint` inherits the batch options, so there's no 
need to duplicate the whole suite. One or two tests in `camel-sjms2` (for 
example batch size, plus transacted rollback) that use the new options against 
the JMS 2.0 component are enough to show the options are wired through.
   
   _Claude Code on behalf of davsclaus_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to