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

Luis Sergio Faria Carneiro updated CAMEL-22387:
-----------------------------------------------
    Description: 
When the Camel context is interrupted during a camel-quartz exchange execution, 
that execution fails (or might fail) with a  {{RejectedExecutionException.}}

Reproducer:

Create integration.yaml:
{code:java}
- from:
    uri: quartz://demo/timer?cron=0+0/1+*+?+*+*
    steps:
    - log:
        message: Calling slow endpoint that will take 30s. Press Ctrl-c before 
it finishes
    - toD:
        uri: "https://teste-luis.free.beeceptor.com/slow-endpoint";
        parameters:
          bridgeEndpoint: true
    - log:
        message: Endpoint result is ${body}
{code}
and application.properties:

 
{code:java}
camel.main.shutdownTimeout=600 {code}
 

and run it with jbang:

{{jbang -Dcamel.jbang.version=4.14.0 camel@apache/camel  run integration.yaml 
application.properties --profile=prod}}

 

This integration runs every minute and calls a slow endpoint that takes about 
30s to complete. If we interrupt the process right after that call, we don't 
see the endpoint result in the log and get this error instead:
{code:java}
2025-08-28 08:34:29.989  INFO 30574 --- [ - ShutdownTask] 
amel.impl.engine.DefaultShutdownStrategy : Waiting as there are still 1 
inflight and pending exchanges to complete, timeout in 576 seconds. Inflights 
per route: [route1 = 1]
2025-08-28 08:34:30.217 ERROR 30574 --- [quartz_Worker-2] 
g.apache.camel.component.quartz.CamelJob : Error processing exchange. 
Exchange[C3DF14D89E49023-0000000000000001]. Caused by: 
[org.quartz.JobExecutionException - 
java.util.concurrent.RejectedExecutionException]
2025-08-28 08:34:30.218  INFO 30574 --- [quartz_Worker-2] 
org.quartz.core.JobRunShell              : Job demo.timer threw a 
JobExecutionException:
org.quartz.JobExecutionException: 
java.util.concurrent.RejectedExecutionException
    at org.apache.camel.component.quartz.CamelJob.execute(CamelJob.java:87) 
~[camel-quartz-4.14.0.jar:4.14.0]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:203) 
[quartz-2.5.0.jar:2.5.0]
    at 
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:566) 
[quartz-2.5.0.jar:2.5.0]
Caused by: java.util.concurrent.RejectedExecutionException
    at 
org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.runNotAllowed(RedeliveryErrorHandler.java:469)
 ~[camel-core-processor-4.14.0.jar:4.14.0]
    at 
org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:402)
 ~[camel-core-processor-4.14.0.jar:4.14.0]
    at 
org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.done(RedeliveryErrorHandler.java:392)
 ~[camel-core-processor-4.14.0.jar:4.14.0]
    at 
org.apache.camel.support.cache.DefaultProducerCache.lambda$doInAsyncProducer$4(DefaultProducerCache.java:292)
 ~[camel-support-4.14.0.jar:4.14.0]
    at 
org.apache.camel.processor.SendDynamicProcessor.lambda$process$0(SendDynamicProcessor.java:245)
 ~[camel-core-processor-4.14.0.jar:4.14.0]
    at 
org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:71)
 ~[camel-support-4.14.0.jar:4.14.0]
    at 
org.apache.camel.processor.SendDynamicProcessor.lambda$process$1(SendDynamicProcessor.java:224)
 ~[camel-core-processor-4.14.0.jar:4.14.0]
    at 
org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProducer(DefaultProducerCache.java:281)
 ~[camel-support-4.14.0.jar:4.14.0]
    at 
org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:204)
 ~[camel-core-processor-4.14.0.jar:4.14.0]
    at 
org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.handleFirst(RedeliveryErrorHandler.java:440)
 ~[camel-core-processor-4.14.0.jar:4.14.0]
    at 
org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:416)
 ~[camel-core-processor-4.14.0.jar:4.14.0]
    at 
org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.doRun(DefaultReactiveExecutor.java:199)
 ~[camel-base-engine-4.14.0.jar:4.14.0]
    at 
org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeReactiveWork(DefaultReactiveExecutor.java:189)
 ~[camel-base-engine-4.14.0.jar:4.14.0]
    at 
org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.tryExecuteReactiveWork(DefaultReactiveExecutor.java:166)
 ~[camel-base-engine-4.14.0.jar:4.14.0]
    at 
org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148)
 ~[camel-base-engine-4.14.0.jar:4.14.0]
    at 
org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59)
 ~[camel-base-engine-4.14.0.jar:4.14.0]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:162) 
~[camel-core-processor-4.14.0.jar:4.14.0]
    at 
org.apache.camel.impl.engine.CamelInternalProcessor.processNonTransacted(CamelInternalProcessor.java:370)
 ~[camel-base-engine-4.14.0.jar:4.14.0]
    at 
org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:346)
 ~[camel-base-engine-4.14.0.jar:4.14.0]
    at 
org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:82)
 ~[camel-base-engine-4.14.0.jar:4.14.0]
    at 
org.apache.camel.support.AsyncProcessorSupport.process(AsyncProcessorSupport.java:32)
 ~[camel-support-4.14.0.jar:4.14.0]
    at org.apache.camel.component.quartz.CamelJob.execute(CamelJob.java:76) 
~[camel-quartz-4.14.0.jar:4.14.0]
    ... 2 more
2025-08-28 08:34:30.949  INFO 30574 --- [ngupInterceptor] 
e.camel.main.DefaultMainShutdownStrategy : Waiting for CamelContext to graceful 
shutdown (max:10m15s0ms, elapsed:25s12ms)
2025-08-28 08:34:31.000  INFO 30574 --- [           main] 
he.camel.component.quartz.QuartzEndpoint : Deleting job demo.timer

{code}
The exception was thrown right after the http call finished, even though a 
second job run hasn't fired.

We may even change the cron mask to something like {{0+50+*+?+*+* }}so it runs 
hourly and still can reproduce the problem.

See full details at:

[https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/camel-quartz.20and.20graceful.20shutdown.20issue/with/536588252]

 

 

  was:
When the Camel context is interrupted during a camel-quartz exchange execution, 
that execution fails (or might fail) with a  {{RejectedExecutionException.}}

Reproducer:

Create integration.yaml:

 ```yaml
- from:
    uri: rest:get:/demo
    steps:
    - log:
        message: Calling slow endpoint that will take 30s. Press Ctrl-c before 
it finishes
    - toD:
        uri: "https://teste-luis.free.beeceptor.com/slow-endpoint";
        parameters:
          bridgeEndpoint: true
    - log:
        message: Endpoint result is ${body}
```

 

 

 

See full details at:

[https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/camel-quartz.20and.20graceful.20shutdown.20issue/with/536588252]

 

 


> camel-quartz graceful shutdown issue
> ------------------------------------
>
>                 Key: CAMEL-22387
>                 URL: https://issues.apache.org/jira/browse/CAMEL-22387
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-quartz
>    Affects Versions: 4.14.0
>            Reporter: Luis Sergio Faria Carneiro
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.14.1, 4.15.0
>
>
> When the Camel context is interrupted during a camel-quartz exchange 
> execution, that execution fails (or might fail) with a  
> {{RejectedExecutionException.}}
> Reproducer:
> Create integration.yaml:
> {code:java}
> - from:
>     uri: quartz://demo/timer?cron=0+0/1+*+?+*+*
>     steps:
>     - log:
>         message: Calling slow endpoint that will take 30s. Press Ctrl-c 
> before it finishes
>     - toD:
>         uri: "https://teste-luis.free.beeceptor.com/slow-endpoint";
>         parameters:
>           bridgeEndpoint: true
>     - log:
>         message: Endpoint result is ${body}
> {code}
> and application.properties:
>  
> {code:java}
> camel.main.shutdownTimeout=600 {code}
>  
> and run it with jbang:
> {{jbang -Dcamel.jbang.version=4.14.0 camel@apache/camel  run integration.yaml 
> application.properties --profile=prod}}
>  
> This integration runs every minute and calls a slow endpoint that takes about 
> 30s to complete. If we interrupt the process right after that call, we don't 
> see the endpoint result in the log and get this error instead:
> {code:java}
> 2025-08-28 08:34:29.989  INFO 30574 --- [ - ShutdownTask] 
> amel.impl.engine.DefaultShutdownStrategy : Waiting as there are still 1 
> inflight and pending exchanges to complete, timeout in 576 seconds. Inflights 
> per route: [route1 = 1]
> 2025-08-28 08:34:30.217 ERROR 30574 --- [quartz_Worker-2] 
> g.apache.camel.component.quartz.CamelJob : Error processing exchange. 
> Exchange[C3DF14D89E49023-0000000000000001]. Caused by: 
> [org.quartz.JobExecutionException - 
> java.util.concurrent.RejectedExecutionException]
> 2025-08-28 08:34:30.218  INFO 30574 --- [quartz_Worker-2] 
> org.quartz.core.JobRunShell              : Job demo.timer threw a 
> JobExecutionException:
> org.quartz.JobExecutionException: 
> java.util.concurrent.RejectedExecutionException
>     at org.apache.camel.component.quartz.CamelJob.execute(CamelJob.java:87) 
> ~[camel-quartz-4.14.0.jar:4.14.0]
>     at org.quartz.core.JobRunShell.run(JobRunShell.java:203) 
> [quartz-2.5.0.jar:2.5.0]
>     at 
> org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:566) 
> [quartz-2.5.0.jar:2.5.0]
> Caused by: java.util.concurrent.RejectedExecutionException
>     at 
> org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.runNotAllowed(RedeliveryErrorHandler.java:469)
>  ~[camel-core-processor-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:402)
>  ~[camel-core-processor-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.done(RedeliveryErrorHandler.java:392)
>  ~[camel-core-processor-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.support.cache.DefaultProducerCache.lambda$doInAsyncProducer$4(DefaultProducerCache.java:292)
>  ~[camel-support-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.processor.SendDynamicProcessor.lambda$process$0(SendDynamicProcessor.java:245)
>  ~[camel-core-processor-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:71)
>  ~[camel-support-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.processor.SendDynamicProcessor.lambda$process$1(SendDynamicProcessor.java:224)
>  ~[camel-core-processor-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProducer(DefaultProducerCache.java:281)
>  ~[camel-support-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:204)
>  ~[camel-core-processor-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.handleFirst(RedeliveryErrorHandler.java:440)
>  ~[camel-core-processor-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:416)
>  ~[camel-core-processor-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.doRun(DefaultReactiveExecutor.java:199)
>  ~[camel-base-engine-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeReactiveWork(DefaultReactiveExecutor.java:189)
>  ~[camel-base-engine-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.tryExecuteReactiveWork(DefaultReactiveExecutor.java:166)
>  ~[camel-base-engine-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148)
>  ~[camel-base-engine-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59)
>  ~[camel-base-engine-4.14.0.jar:4.14.0]
>     at org.apache.camel.processor.Pipeline.process(Pipeline.java:162) 
> ~[camel-core-processor-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.impl.engine.CamelInternalProcessor.processNonTransacted(CamelInternalProcessor.java:370)
>  ~[camel-base-engine-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:346)
>  ~[camel-base-engine-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:82)
>  ~[camel-base-engine-4.14.0.jar:4.14.0]
>     at 
> org.apache.camel.support.AsyncProcessorSupport.process(AsyncProcessorSupport.java:32)
>  ~[camel-support-4.14.0.jar:4.14.0]
>     at org.apache.camel.component.quartz.CamelJob.execute(CamelJob.java:76) 
> ~[camel-quartz-4.14.0.jar:4.14.0]
>     ... 2 more
> 2025-08-28 08:34:30.949  INFO 30574 --- [ngupInterceptor] 
> e.camel.main.DefaultMainShutdownStrategy : Waiting for CamelContext to 
> graceful shutdown (max:10m15s0ms, elapsed:25s12ms)
> 2025-08-28 08:34:31.000  INFO 30574 --- [           main] 
> he.camel.component.quartz.QuartzEndpoint : Deleting job demo.timer
> {code}
> The exception was thrown right after the http call finished, even though a 
> second job run hasn't fired.
> We may even change the cron mask to something like {{0+50+*+?+*+* }}so it 
> runs hourly and still can reproduce the problem.
> See full details at:
> [https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/camel-quartz.20and.20graceful.20shutdown.20issue/with/536588252]
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to