Apache Camel. Исключение java.util.concurrent.RejectedExecutionException при попытке остановить работающий роут

У меня написано интеграционное приложение, собирающее данные через REST API поставщиков. Все роуты, опрашивающие методы API, снабжены defaultErrorHandler, который повторяет отправку сообщений до 5 раз при ошибках. Все работает, роуты запускаются и останавливаются из панели Swagger. Проблема возникает, когда я пытаюсь остановить работающий роут, который судя по всему, распараллеливается фреймворком и выполняется в несколько потоков. Роуты, где параллельное выполнение не возможно, останавливаются без ошибок.

Я где-то на форумах читал ответы самого Клауса Ибсена о том, что в таких случаях надо запускать отдельный контекст Camel и из него останавливать роут в текущем контексте, но практической реализации этого способа нигде не нашел. Может быть это все же где-то реализовано, только я не знаю где?

Вот лог приложения. Роут запускается, работает, дается команда на остановку, появляется куча inflight and pending exchanges и под конец вылетает исключение java.util.concurrent.RejectedExecutionException

Как решить проблему? Кто сталкивался, пожалуйста дайте наводку в какую сторону копать.

2025-01-29T20:20:17.797+03:00 INFO 16760 --- [nio-9090-exec-5] o.p.i.config.StartStopRoutesConfig : Gracefully starting route ReliefRoutePricesContract 2025-01-29T20:20:18.808+03:00 INFO 16760 --- [outePricesTimer] o.p.i.r.r.ReliefRoutePricesContract : Relief Prices is started at: Wed Jan 29 20:20:18 MSK 2025 by Timer:manualStartReliefRoutePricesTimer 2025-01-29T20:20:18.809+03:00 INFO 16760 --- [outePricesTimer] o.p.i.r.r.ReliefRoutePricesContract
: Truncating table relief_row_data_prices started... 2025-01-29T20:20:18.872+03:00 INFO 16760 --- [outePricesTimer] o.p.i.r.r.ReliefRoutePricesContract : [{__relief_truncate_prices_row_data_table={"status" : {"status" : "ok"}, "message" : "Функция __relief_truncate_prices_row_data_table выполнена успешно."}}] 2025-01-29T20:20:18.873+03:00 INFO 16760 --- [outePricesTimer] o.p.i.r.r.ReliefRoutePricesContract : Truncating table relief_row_data_prices finished... 2025-01-29T20:20:18.873+03:00 INFO 16760 --- [outePricesTimer] o.p.i.config.StartStopRoutesConfig : Gracefully stopping route cronStartReliefRoutePricesContract 2025-01-29T20:20:18.874+03:00 INFO 16760 --- [outePricesTimer] o.a.c.impl.engine.AbstractCamelContext : Stopped cronStartReliefRoutePricesContract (cron://ReliefRoutePricesContractSchedule) 2025-01-29T20:20:18.874+03:00 INFO 16760 --- [outePricesTimer] o.p.i.config.StartStopRoutesConfig : Gracefully stopping route ReliefRoutePricesContract 2025-01-29T20:20:18.876+03:00 INFO 16760 --- [outePricesTimer] o.a.c.impl.engine.AbstractCamelContext : Stopped ReliefRoutePricesContract (direct://doProcessingReliefRoutePricesContract) 2025-01-29T20:20:18.877+03:00 INFO 16760 --- [outePricesTimer] o.p.i.config.StartStopRoutesConfig : Gracefully starting route ReliefRoutePricesContract 2025-01-29T20:20:18.927+03:00 INFO 16760 --- [outePricesTimer] o.p.i.r.p.r.ReliefSqlCycleProcessor : Execution of task will take 37 iteration of 2500 items each. Please, wait... 2025-01-29T20:20:18.929+03:00 INFO 16760 --- [outePricesTimer] ReliefRoutePricesContract : Relief Prices Contract - Current Iteration: 0 2025-01-29T20:20:25.513+03:00 INFO 16760 --- [outePricesTimer] ReliefRoutePricesContract
: Relief Prices Contract - Current Iteration: 1 2025-01-29T20:20:30.557+03:00 INFO 16760 --- [nio-9090-exec-6] o.p.i.c.ReliefIntegrationController : get request is received for manual stop ReliefRoutePricesContract 2025-01-29T20:20:30.557+03:00 INFO 16760 --- [nio-9090-exec-6] o.p.i.config.StartStopRoutesConfig
: Gracefully stopping route manualStartReliefRoutePricesContract 2025-01-29T20:20:30.560+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 10 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:31.571+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 9 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:32.863+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 8 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:34.012+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 7 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:34.410+03:00 INFO 16760 --- [outePricesTimer] ReliefRoutePricesContract : Relief Prices Contract - Current Iteration: 2 2025-01-29T20:20:35.160+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 6 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:36.174+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 5 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:37.183+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 4 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:38.190+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 3 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:39.192+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 2 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:40.205+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 1 seconds. Inflights per route: [manualStartReliefRoutePricesContract = 1] 2025-01-29T20:20:40.563+03:00 WARN 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Interrupted while waiting during graceful shutdown, will force shutdown now. 2025-01-29T20:20:40.563+03:00 WARN 16760 --- [nio-9090-exec-6] o.a.c.i.engine.DefaultShutdownStrategy : Timeout occurred during graceful shutdown. Forcing the routes to be shutdown now. Notice: some resources may still be running as graceful shutdown did not complete successfully. 2025-01-29T20:20:40.564+03:00 INFO 16760 --- [nio-9090-exec-6] o.a.c.impl.engine.AbstractCamelContext : Stopped manualStartReliefRoutePricesContract (timer://manualStartReliefRoutePricesTimer) 2025-01-29T20:20:40.564+03:00 INFO 16760 --- [nio-9090-exec-6] o.p.i.config.StartStopRoutesConfig : Gracefully stopping route ReliefRoutePricesContract 2025-01-29T20:20:40.565+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 246 inflight and pending exchanges to complete, timeout in 10 seconds. Inflights per route: [ReliefRoutePricesContract = 246] 2025-01-29T20:20:41.576+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 246 inflight and pending exchanges to complete, timeout in 9 seconds. Inflights per route: [ReliefRoutePricesContract = 246] 2025-01-29T20:20:41.652+03:00 INFO 16760 --- [outePricesTimer] ReliefRoutePricesContract : Relief Prices Contract - Current Iteration: 3 2025-01-29T20:20:42.583+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 239 inflight and pending exchanges to complete, timeout in 8 seconds. Inflights per route: [ReliefRoutePricesContract = 239] 2025-01-29T20:20:43.598+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 239 inflight and pending exchanges to complete, timeout in 7 seconds. Inflights per route: [ReliefRoutePricesContract = 239] 2025-01-29T20:20:44.613+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 239 inflight and pending exchanges to complete, timeout in 6 seconds. Inflights per route: [ReliefRoutePricesContract = 239] 2025-01-29T20:20:45.620+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 239 inflight and pending exchanges to complete, timeout in 5 seconds. Inflights per route: [ReliefRoutePricesContract = 239] 2025-01-29T20:20:46.634+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 239 inflight and pending exchanges to complete, timeout in 4 seconds. Inflights per route: [ReliefRoutePricesContract = 239] 2025-01-29T20:20:47.644+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 239 inflight and pending exchanges to complete, timeout in 3 seconds. Inflights per route: [ReliefRoutePricesContract = 239] 2025-01-29T20:20:47.816+03:00 INFO 16760 --- [outePricesTimer] ReliefRoutePricesContract : Relief Prices Contract - Current Iteration: 4 2025-01-29T20:20:48.656+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 232 inflight and pending exchanges to complete, timeout in 2 seconds. Inflights per route: [ReliefRoutePricesContract = 232] 2025-01-29T20:20:49.667+03:00 INFO 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Waiting as there are still 232 inflight and pending exchanges to complete, timeout in 1 seconds. Inflights per route: [ReliefRoutePricesContract = 232] 2025-01-29T20:20:50.567+03:00 WARN 16760 --- [nio-9090-exec-6] o.a.c.i.engine.DefaultShutdownStrategy : Timeout occurred during graceful shutdown. Forcing the routes to be shutdown now. Notice: some resources may still be running as graceful shutdown did not complete successfully. 2025-01-29T20:20:50.567+03:00 WARN 16760 --- [ - ShutdownTask] o.a.c.i.engine.DefaultShutdownStrategy : Interrupted while waiting during graceful shutdown, will force shutdown now. 2025-01-29T20:20:50.568+03:00 INFO 16760 --- [nio-9090-exec-6] o.a.c.impl.engine.AbstractCamelContext : Stopped ReliefRoutePricesContract (direct://doProcessingReliefRoutePricesContract) 2025-01-29T20:20:52.218+03:00 WARN 16760 --- [outePricesTimer] o.a.camel.component.timer.TimerConsumer : Error processing exchange. Exchange[D8EBD09FAE0BADF-0000000000000000]. Caused by: [java.util.concurrent.RejectedExecutionException - null]

java.util.concurrent.RejectedExecutionException: null at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.run(RedeliveryErrorHandler.java:705) ~[camel-core-processor-4.8.1.jar:4.8.1] at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.doRun(DefaultReactiveExecutor.java:199) ~[camel-base-engine-4.8.1.jar:4.8.1] at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.executeReactiveWork(DefaultReactiveExecutor.java:189) ~[camel-base-engine-4.8.1.jar:4.8.1] at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.tryExecuteReactiveWork(DefaultReactiveExecutor.java:166) ~[camel-base-engine-4.8.1.jar:4.8.1] at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148) ~[camel-base-engine-4.8.1.jar:4.8.1] at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59) ~[camel-base-engine-4.8.1.jar:4.8.1] at org.apache.camel.processor.Pipeline.process(Pipeline.java:163) ~[camel-core-processor-4.8.1.jar:4.8.1] at org.apache.camel.impl.engine.CamelInternalProcessor.processNonTransacted(CamelInternalProcessor.java:347) ~[camel-base-engine-4.8.1.jar:4.8.1] at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:323) ~[camel-base-engine-4.8.1.jar:4.8.1] at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:293) ~[camel-timer-4.8.1.jar:4.8.1] at org.apache.camel.component.timer.TimerConsumer$1.doRun(TimerConsumer.java:164) ~[camel-timer-4.8.1.jar:4.8.1] at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:136) ~[camel-timer-4.8.1.jar:4.8.1] at java.base/java.util.TimerThread.mainLoop(Timer.java:566) ~[na:na] at java.base/java.util.TimerThread.run(Timer.java:516) ~[na:na]


Ответы (0 шт):