Pasquale Congiusti created CAMEL-21599: ------------------------------------------
Summary: Global Error Handler fail when a Kamelet fails Key: CAMEL-21599 URL: https://issues.apache.org/jira/browse/CAMEL-21599 Project: Camel Issue Type: Bug Affects Versions: 4.9.0 Reporter: Pasquale Congiusti I found a faulty behavior when configuring a global error handler and the failure is caused by the execution of a Kamelet. The following route works correctly: {code} - route: errorHandler: deadLetterChannel: deadLetterUri: kamelet:log-sink/errorHandler from: uri: timer:tick steps: - setBody: constant: "fail!" - setBody: simple: "${mandatoryBodyAs(Boolean)}" - log: "${body}" {code} It intercept the failing execution and forward the failure to the DLC. However, if the producer URI contains a failing Kamelet, then, the global error handler is not working. Wrapping the same failing logic in a local Kamelet like: {code} apiVersion: camel.apache.org/v1 kind: Kamelet metadata: name: my-err-source labels: camel.apache.org/kamelet.type: "source" spec: definition: title: "Timer Example" description: "Produces periodic events with a custom payload" required: - message properties: period: title: Period description: The time interval between two events type: integer default: 1000 message: title: Message description: The message to generate type: string types: out: mediaType: text/plain template: from: uri: timer:tick parameters: period: "{{period}}" steps: - setBody: constant: "{{message}}" - setBody: simple: "${mandatoryBodyAs(Boolean)}" - setHeader: name: "Content-Type" constant: "text/plain" - to: "kamelet:sink" {code} And executing a new route as: {code} - route: errorHandler: deadLetterChannel: deadLetterUri: kamelet:log-sink/errorHandler from: uri: "kamelet:my-err-source/source" parameters: message: "fail!" steps: - log: "${body}" {code} Will act as no error handler is set at all, logging a Warn: {code} $ camel run * 2025-01-07 15:35:45.263 INFO 610120 --- [ main] org.apache.camel.main.MainSupport : Apache Camel (JBang) 4.9.0 is starting 2025-01-07 15:35:45.332 INFO 610120 --- [ main] org.apache.camel.main.MainSupport : Additional files added to classpath: console.log 2025-01-07 15:35:45.478 INFO 610120 --- [ main] org.apache.camel.main.MainSupport : Using Java 17.0.7 with PID 610120. Started by squake in /home/squake/workspace/camel-k/kamelet 2025-01-07 15:35:45.615 INFO 610120 --- [ main] org.apache.camel.main.ProfileConfigurer : The application is starting with profile: dev 2025-01-07 15:35:45.970 INFO 610120 --- [ main] he.camel.cli.connector.LocalCliConnector : Camel JBang CLI enabled 2025-01-07 15:35:46.124 INFO 610120 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) is starting 2025-01-07 15:35:46.390 INFO 610120 --- [ main] e.camel.impl.engine.AbstractCamelContext : Routes startup (total:1 started:1 kamelets:1) 2025-01-07 15:35:46.390 INFO 610120 --- [ main] e.camel.impl.engine.AbstractCamelContext : Started route1 (timer://tick) 2025-01-07 15:35:46.391 INFO 610120 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) started in 266ms (build:0ms init:0ms start:266ms boot:858ms) 2025-01-07 15:35:47.329 INFO 610120 --- [ - timer://tick] log-sink : Exchange[ExchangePattern: InOnly, BodyType: String, Body: fail!] 2025-01-07 15:35:48.283 INFO 610120 --- [ - timer://tick] log-sink : Exchange[ExchangePattern: InOnly, BodyType: String, Body: fail!] 2025-01-07 15:35:49.283 INFO 610120 --- [ - timer://tick] log-sink : Exchange[ExchangePattern: InOnly, BodyType: String, Body: fail!] ^C2025-01-07 15:35:49.678 INFO 610120 --- [ngupInterceptor] e.camel.main.DefaultMainShutdownStrategy : JVM shutdown hook triggered by SIGTERM (PID 610120). Shutting down Apache Camel (JBang) 4.9.0 2025-01-07 15:35:49.682 INFO 610120 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) is shutting down (timeout:10s) 2025-01-07 15:35:49.712 INFO 610120 --- [ main] e.camel.impl.engine.AbstractCamelContext : Routes stopped (total:1 stopped:1 kamelets:1) 2025-01-07 15:35:49.712 INFO 610120 --- [ main] e.camel.impl.engine.AbstractCamelContext : Stopped route1 (timer://tick) 2025-01-07 15:35:49.720 INFO 610120 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) shutdown in 37ms (uptime:3s) 2025-01-07 15:35:49.720 INFO 610120 --- [ main] org.apache.camel.main.MainSupport : Apache Camel (JBang) 4.9.0 shutdown 2025-01-07 15:35:49.720 INFO 610120 --- [ngupInterceptor] e.camel.main.DefaultMainShutdownStrategy : Apache Camel (JBang) 4.9.0 is shutdown squake:~/workspace/camel-k/kamelet [fix/plain_quarkus_2]$ camel run * 2025-01-07 15:36:08.970 INFO 610742 --- [ main] org.apache.camel.main.MainSupport : Apache Camel (JBang) 4.9.0 is starting 2025-01-07 15:36:09.035 INFO 610742 --- [ main] org.apache.camel.main.MainSupport : Additional files added to classpath: console.log 2025-01-07 15:36:09.170 INFO 610742 --- [ main] org.apache.camel.main.MainSupport : Using Java 17.0.7 with PID 610742. Started by squake in /home/squake/workspace/camel-k/kamelet 2025-01-07 15:36:09.346 INFO 610742 --- [ main] org.apache.camel.main.ProfileConfigurer : The application is starting with profile: dev 2025-01-07 15:36:09.684 INFO 610742 --- [ main] he.camel.cli.connector.LocalCliConnector : Camel JBang CLI enabled 2025-01-07 15:36:09.813 INFO 610742 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) is starting 2025-01-07 15:36:10.052 INFO 610742 --- [ main] e.camel.impl.engine.AbstractCamelContext : Routes startup (total:1 started:1 kamelets:1) 2025-01-07 15:36:10.052 INFO 610742 --- [ main] e.camel.impl.engine.AbstractCamelContext : Started route1 (timer://tick) 2025-01-07 15:36:10.052 INFO 610742 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) started in 238ms (build:0ms init:0ms start:238ms boot:840ms) 2025-01-07 15:36:11.005 INFO 610742 --- [ - timer://tick] log-sink : Exchange[ExchangePattern: InOnly, BodyType: String, Body: fail!] 2025-01-07 15:36:11.952 INFO 610742 --- [ - timer://tick] log-sink : Exchange[ExchangePattern: InOnly, BodyType: String, Body: fail!] 2025-01-07 15:36:12.952 INFO 610742 --- [ - timer://tick] log-sink : Exchange[ExchangePattern: InOnly, BodyType: String, Body: fail!] ^C2025-01-07 15:36:13.216 INFO 610742 --- [ngupInterceptor] e.camel.main.DefaultMainShutdownStrategy : JVM shutdown hook triggered by SIGTERM (PID 610742). Shutting down Apache Camel (JBang) 4.9.0 2025-01-07 15:36:13.220 INFO 610742 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) is shutting down (timeout:10s) 2025-01-07 15:36:13.246 INFO 610742 --- [ main] e.camel.impl.engine.AbstractCamelContext : Routes stopped (total:1 stopped:1 kamelets:1) 2025-01-07 15:36:13.247 INFO 610742 --- [ main] e.camel.impl.engine.AbstractCamelContext : Stopped route1 (timer://tick) 2025-01-07 15:36:13.270 INFO 610742 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) shutdown in 50ms (uptime:3s) 2025-01-07 15:36:13.271 INFO 610742 --- [ main] org.apache.camel.main.MainSupport : Apache Camel (JBang) 4.9.0 shutdown 2025-01-07 15:36:13.271 INFO 610742 --- [ngupInterceptor] e.camel.main.DefaultMainShutdownStrategy : Apache Camel (JBang) 4.9.0 is shutdown squake:~/workspace/camel-k/kamelet [fix/plain_quarkus_2]$ camel run * 2025-01-07 15:36:45.452 INFO 611589 --- [ main] org.apache.camel.main.MainSupport : Apache Camel (JBang) 4.9.0 is starting 2025-01-07 15:36:45.522 INFO 611589 --- [ main] org.apache.camel.main.MainSupport : Additional files added to classpath: console.log 2025-01-07 15:36:45.652 INFO 611589 --- [ main] org.apache.camel.main.MainSupport : Using Java 17.0.7 with PID 611589. Started by squake in /home/squake/workspace/camel-k/kamelet 2025-01-07 15:36:45.837 INFO 611589 --- [ main] org.apache.camel.main.ProfileConfigurer : The application is starting with profile: dev 2025-01-07 15:36:46.197 INFO 611589 --- [ main] he.camel.cli.connector.LocalCliConnector : Camel JBang CLI enabled 2025-01-07 15:36:46.350 INFO 611589 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) is starting 2025-01-07 15:36:46.497 INFO 611589 --- [ main] org.apache.camel.main.BaseMainSupport : Property-placeholders summary 2025-01-07 15:36:46.498 INFO 611589 --- [ main] org.apache.camel.main.BaseMainSupport : [my-err-source.kamelet.yaml] message = fail! 2025-01-07 15:36:46.611 INFO 611589 --- [ main] e.camel.impl.engine.AbstractCamelContext : Routes startup (total:1 started:1 kamelets:2) 2025-01-07 15:36:46.612 INFO 611589 --- [ main] e.camel.impl.engine.AbstractCamelContext : Started route1 (kamelet://my-err-source/source) 2025-01-07 15:36:46.612 INFO 611589 --- [ main] e.camel.impl.engine.AbstractCamelContext : Apache Camel 4.9.0 (my-err-source) started in 261ms (build:0ms init:0ms start:261ms boot:895ms) 2025-01-07 15:36:47.543 WARN 611589 --- [ - timer://tick] ache.camel.component.timer.TimerConsumer : Error processing exchange. Exchange[FE1CC7B02A4822F-0000000000000000]. Caused by: [org.apache.camel.CamelExecutionException - Exception occurred during execution on the exchange: Exchange[FE1CC7B02A4822F-0000000000000000]] org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[FE1CC7B02A4822F-0000000000000000] at org.apache.camel.CamelExecutionException.wrapCamelExecutionException(CamelExecutionException.java:45) ~[camel-api-4.9.0.jar:4.9.0] at org.apache.camel.language.simple.SimpleExpressionBuilder$31.evaluate(SimpleExpressionBuilder.java:838) ~[camel-core-languages-4.9.0.jar:4.9.0] at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:45) ~[camel-support-4.9.0.jar:4.9.0] at org.apache.camel.processor.SetBodyProcessor.process(SetBodyProcessor.java:45) ~[camel-core-processor-4.9.0.jar:4.9.0] at org.apache.camel.processor.errorhandler.NoErrorHandler.process(NoErrorHandler.java:46) ~[camel-core-processor-4.9.0.jar:4.9.0] at org.apache.camel.impl.engine.CamelInternalProcessor.processNonTransacted(CamelInternalProcessor.java:347) ~[camel-base-engine-4.9.0.jar:4.9.0] at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:323) ~[camel-base-engine-4.9.0.jar:4.9.0] at org.apache.camel.processor.Pipeline$PipelineTask.run(Pipeline.java:102) ~[camel-core-processor-4.9.0.jar:4.9.0] at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.doRun(DefaultReactiveExecutor.java:199) [camel-base-engine-4.9.0.jar:4.9.0] at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeReactiveWork(DefaultReactiveExecutor.java:189) [camel-base-engine-4.9.0.jar:4.9.0] at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.tryExecuteReactiveWork(DefaultReactiveExecutor.java:166) [camel-base-engine-4.9.0.jar:4.9.0] at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148) [camel-base-engine-4.9.0.jar:4.9.0] at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59) [camel-base-engine-4.9.0.jar:4.9.0] at org.apache.camel.processor.Pipeline.process(Pipeline.java:163) [camel-core-processor-4.9.0.jar:4.9.0] at org.apache.camel.impl.engine.CamelInternalProcessor.processNonTransacted(CamelInternalProcessor.java:347) [camel-base-engine-4.9.0.jar:4.9.0] at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:323) [camel-base-engine-4.9.0.jar:4.9.0] at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:293) [camel-timer-4.9.0.jar:4.9.0] at org.apache.camel.component.timer.TimerConsumer$1.doRun(TimerConsumer.java:164) [camel-timer-4.9.0.jar:4.9.0] at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:136) [camel-timer-4.9.0.jar:4.9.0] at java.base/java.util.TimerThread.mainLoop(Timer.java:566) [?:?] at java.base/java.util.TimerThread.run(Timer.java:516) [?:?] {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)