[ 
https://issues.apache.org/jira/browse/CAMEL-27515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150333#comment-18150333
 ] 

Claus Ibsen commented on CAMEL-27515:
-------------------------------------

Yeah the Error should not be part of Camel routing / error handling. The 
original report about this was due to the JVM was not configured to shutdown on 
Error. And users would like to have the Error logged at ERROR before the JVM is 
shutdown and if possible give inflight messages time to quickly finish if they 
can.

But if a JVM is OOME then it may not be possible to finish pending inflight 
messages, but the important thing is that the Error is logged so there is 
evidence of why/where the OOME happened.

> camel-core - after a VirtualMachineError thrown by a processor, the rest of 
> the route runs later on the next exchange of the same thread
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27515
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27515
>             Project: Camel
>          Issue Type: Sub-task
>          Components: camel-core
>            Reporter: Federico Mariani
>            Assignee: Federico Mariani
>            Priority: Major
>
> A plain {{Processor}} that throws a {{VirtualMachineError}} 
> ({{OutOfMemoryError}}, {{StackOverflowError}}) leaves the rest of its route 
> queued on the thread. The next exchange processed on that thread runs it: the 
> failed exchange goes on through its route, with no exception set, as if the 
> processor had succeeded.
> {{DelegateSyncProcessor}} (and the bridge of 
> {{AsyncProcessorConverterHelper}}) calls the callback in {{finally}}, then 
> throws the {{VirtualMachineError}} on, with no exception set on the exchange. 
> The callback queues the next step of the route on the reactive worker of the 
> thread. The {{Error}} then leaves {{DefaultReactiveExecutor}}, whose 
> {{doRun}} catches only {{Exception}}, and the queued step stays there until 
> the next exchange on that thread runs it. CAMEL-26741 fixed this for the 
> other {{Error}}s and left a {{VirtualMachineError}} as before. 
> {{error-handler.adoc}} says that the exchange may stay inflight, but not that 
> it can go on later.
> Reproduced on 4.18.5, 4.23.0 and main:
> {code:java}
> from("direct:a")
>     .process(e -> { throw new StackOverflowError("simulated"); })
>     .process(e -> probe.add("route a step 2: body=" + 
> e.getMessage().getBody() + " exception=" + e.getException()));
> from("direct:b").process(e -> probe.add("route b"));
> template.sendBody("direct:a", "to-a"); // throws the StackOverflowError, 
> probe is empty
> template.sendBody("direct:b", "to-b"); // probe = [route b, route a step 2: 
> body=to-a exception=null]
> {code}
> Why it matters now: the consumer fixes under CAMEL-27469 keep the thread 
> alive after a {{VirtualMachineError}}.
> * With CAMEL-27470 merged, take two timer routes on the same timer. After 
> route A throws, its next step runs on a tick of route B, after the ERROR line 
> said that route A no longer fires. With the pooled exchange factory and 
> {{synchronous=true}}, it runs on an exchange that {{TimerConsumer}} has 
> already released and reset, so it gets an empty message.
> * A loop that goes on after a {{VirtualMachineError}}, as planned for 
> camel-seda in CAMEL-27471, would run it on its next exchange.
> * When nothing else runs on the thread, the exchange stays inflight, and 
> stopping the route waits for the shutdown timeout.
> Possible fixes, to agree on CAMEL-27469:
> * Before calling the callback, mark the exchange so that the queued steps do 
> not run and its on completions see a failure. The {{Error}} is still thrown 
> on, and still not given to Camel's error handling (CAMEL-26741).
> * Do not call the callback for a {{VirtualMachineError}}. Nothing is queued, 
> but a caller that waits for the callback on another thread would wait forever.
> * The reactive worker drops the queued work of the failed exchange when an 
> {{Error}} leaves {{doRun}}, without dropping unrelated work.
> A test: a route with two steps where the first throws a 
> {{StackOverflowError}}, then another exchange on the same thread. The second 
> step and the on completions of the first exchange must not run.
> _Claude Code on behalf of Croway_



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

Reply via email to