[ 
https://issues.apache.org/jira/browse/CAMEL-27331?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-27331 started by shashank.
----------------------------------------
> camel-core - Resequence EIP: batch mode loses the exchanges waiting for the 
> current batch when the route is stopped and started
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27331
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27331
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>
> h3. What happens
> The batch resequencer completes an exchange as soon as it has queued a copy 
> of it ({{Resequencer.process}} calls {{callback.done(true)}} after 
> {{enqueueExchange}}). The copy waits in the queue of the {{BatchSender}} 
> thread until the batch is complete (size, completion predicate or timeout).
> Each start creates a new {{BatchSender}} with a new, empty queue (since 
> CAMEL-20435), and {{doStop}} cancels the old one, which never drains its 
> queue again. So when the route is stopped and started while exchanges wait 
> for the batch, those exchanges are lost, although their callers were told 
> that they succeeded.
> The sorted {{collection}} is kept over a restart and sent by the next sender 
> (CAMEL-26634), and the stream resequencer keeps its held messages over a 
> restart (CAMEL-25053); only the queue is lost.
> What restarts the processor: stopRoute / startRoute (API, JMX, controlbus), 
> ClusteredRoutePolicy, the quartz ScheduledRoutePolicy.
> h3. How to reproduce
> {code:java}
> from("direct:start").routeId("batch")
>     .resequence(header("seq")).batch().size(10).timeout(2000)
>     .to("mock:result");
> {code}
> Send two exchanges (both return without an exception), then stopRoute and 
> startRoute within 2 seconds: mock:result never receives them.
> Found with a TLA+ model of the batch resequencer.
> h3. Fix
> Move the queue (with its lock, condition and flags) from the sender to the 
> processor, next to {{collection}}, so the sender of the next start delivers 
> the waiting exchanges. A stopped processor rejects new exchanges with a 
> RejectedExecutionException instead of a NullPointerException.
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to