Hi Camel Community,
Greetings to you!
Camel version: 3.20.4
Spring Boot version: 2.7.11
JDK: Amazon Corretto 17
Platform: Windows server 2019
IDE: IntelliJ IDEA 2021.3.2 (Community Edition)
Stack Traces & logging output: attached at the end
I have a case that two routes use the same HTTP listening URL but different
backend, one is mater and another is backup. Normally during the Camel start
only master route should be started, the backup route should be in stop status.
When the master route corresponding backend got issue we can manually start the
backup route and stop the master route.
The problem is that during Camel startup it will try to start all routes and
failed due to below error:
---
Application run
failed","logger_name":"org.springframework.boot.SpringApplication","thread_name":"main","level":"ERROR","level_value":40000,"stack_trace":"org.apache.camel.FailedToStartRouteException:
Failed to start route SMS_JSON_MsgFlow because of Multiple consumers for the same endpoint is not allowed:
jetty:http://0.0.0.0:7806/esb00/helmjson?httpMethodRestrict=POST&matchOnUriPrefix=true
---
I read the Camel document and seems RoutePolicy[1] could be the solution, so I take class
ThrottlingInflightRoutePolicy as reference and extend class RoutePolicySupport and
override method onStart as below, however seems it not works. I can see it print the log
"stop omni channel interface: " on console but the CamelContext still try to
start the route and got issue.
Could you kindly advise on this? Thanks in advance!
---
@Override
public void onStart(Route route) {
System.out.println("starting route: " + route.getRouteId());
boolean startOmniChannel =
Boolean.parseBoolean(String.valueOf(camelContext.getPropertiesComponent().resolveProperty("start_omni_channel")));
if (!startOmniChannel) {
try {
System.out.println("stop omni channel interface: " +
route.getRouteId());
suspendOrStopConsumer(route.getConsumer());
} catch (Exception e) {
e.printStackTrace();
}
}
}
---
Stack Traces & logging output:
---
{"@timestamp":"2023-08-28T10:58:07.52+08:00","@version":"1","message":"Apache Camel 3.20.4 (mini-esb) is
starting","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:07.62+08:00","@version":"1","message":"Starting CamelMainRunController to ensure the main thread keeps
running","logger_name":"org.apache.camel.spring.boot.CamelSpringBootApplicationListener","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:07.622+08:00","@version":"1","message":"Apache Camel (Main) 3.20.4 is
starting","logger_name":"org.apache.camel.main.MainSupport","thread_name":"CamelMainRunController","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:07.642+08:00","@version":"1","message":"Logging initialized @5011ms to
org.eclipse.jetty.util.log.Slf4jLog","logger_name":"org.eclipse.jetty.util.log","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:08.1+08:00","@version":"1","message":"jetty-9.4.51.v20230217; built: 2023-02-17T08:19:37.309Z; git:
b45c405e4544384de066f814ed42ae3dceacdd49; jvm
17.0.7+7-LTS","logger_name":"org.eclipse.jetty.server.Server","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:08.53+08:00","@version":"1","message":"Started
o.e.j.s.ServletContextHandler@4c635edc{/,null,AVAILABLE}","logger_name":"org.eclipse.jetty.server.handler.ContextHandler","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:08.994+08:00","@version":"1","message":"Started ServerConnector@3009eed7{HTTP/1.1,
(http/1.1)}{0.0.0.0:7806}","logger_name":"org.eclipse.jetty.server.AbstractConnector","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:08.994+08:00","@version":"1","message":"Started
@6363ms","logger_name":"org.eclipse.jetty.server.Server","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.011+08:00","@version":"1","message":"Error starting CamelContext (mini-esb) due to exception thrown: Failed to start route SMS_JSON_MsgFlow because
of Multiple consumers for the same endpoint is not allowed:
jetty:http://0.0.0.0:7806/esb00/helmjson?httpMethodRestrict=POST&matchOnUriPrefix=true","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"ERROR","level_value":40000,"stack_trace":"org.apache.camel.FailedToStartRouteException:
Failed to start route SMS_JSON_MsgFlow because of Multiple consumers for the same endpoint is not allowed: jetty:http://0.0.0.0:7806/esb00/helmjson?httpMethodRestrict=POST&matchOnUriPrefix=true\r\n\tat
org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRouteConsumers(InternalRouteStartupManager.java:357)\r\n\tat
org.apache.camel.impl.engine.InternalRouteStartupManager.doStartRouteConsumers(InternalRouteStartupManager.java:319)\r\n\tat
org.apache.camel.impl.engine.InternalRouteStartupManager.safelyStartRouteServices(InternalRouteStartupManager.java:213)\r\n\tat
org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRoutes(InternalRouteStartupManager.java:147)\r\n\tat org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:3434)\r\n\tat
org.apache.camel.impl.engine.AbstractCamelContext.doStartContext(AbstractCamelContext.java:3103)\r\n\tat org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:3058)\r\n\tat
org.apache.camel.spring.boot.SpringBootCamelContext.doStart(SpringBootCamelContext.java:43)\r\n\tat org.apache.camel.support.service.BaseService.start(BaseService.java:119)\r\n\tat
org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2707)\r\n\tat org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262)\r\n\tat
org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:119)\r\n\tat org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:151)\r\n\tat
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)\r\n\tat
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)\r\n\tat
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)\r\n\tat
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)\r\n\tat
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)\r\n\tat
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:940)\r\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)\r\n\tat
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)\r\n\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)\r\n\tat
org.springframework.boot.SpringApplication.run(SpringApplication.java:307)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)\r\n\tat
org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)\r\n\tat com.mbfscn.esb.runtime.MiniESBApplication.main(MiniESBApplication.java:16)\r\n"}
{"@timestamp":"2023-08-28T10:58:09.015+08:00","@version":"1","message":"Apache Camel 3.20.4 (mini-esb) is shutting down
(timeout:45s)","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.027+08:00","@version":"1","message":"Stopped ServerConnector@3009eed7{HTTP/1.1,
(http/1.1)}{0.0.0.0:7806}","logger_name":"org.eclipse.jetty.server.AbstractConnector","thread_name":"Camel (mini-esb) thread #1 -
ShutdownTask","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.03+08:00","@version":"1","message":"Stopped
o.e.j.s.ServletContextHandler@4c635edc{/,null,STOPPED}","logger_name":"org.eclipse.jetty.server.handler.ContextHandler","thread_name":"Camel (mini-esb) thread #1 -
ShutdownTask","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.037+08:00","@version":"1","message":"Routes stopped
(stopped:5)","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.037+08:00","@version":"1","message":" Stopped Mini_esb_dynamic_route_controller
(jetty:http://0.0.0.0:7806/esb06/dynamicRouteController)","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.037+08:00","@version":"1","message":" Stopped Mini_esb_smtp
(direct://mini-esb-smtp)","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.037+08:00","@version":"1","message":" Stopped SMS_JSON_MsgFlow
(jetty:http://0.0.0.0:7806/esb00/helmjson)","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.038+08:00","@version":"1","message":" Stopped SMS_XML_MsgFlow
(jetty:http://0.0.0.0:7806/esb00/helm/)","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.038+08:00","@version":"1","message":" Stopped HELM_JSON_SMS_MsgFlow
(jetty:http://0.0.0.0:7806/esb00/helmjson)","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.041+08:00","@version":"1","message":"Apache Camel 3.20.4 (mini-esb) shutdown in 25ms
(uptime:1s)","logger_name":"org.apache.camel.impl.engine.AbstractCamelContext","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.048+08:00","@version":"1","message":"\r\n\r\nError starting ApplicationContext. To display the conditions report re-run
your application with 'debug'
enabled.","logger_name":"org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener","thread_name":"main","level":"INFO","level_value":20000}
{"@timestamp":"2023-08-28T10:58:09.218+08:00","@version":"1","message":"Application run
failed","logger_name":"org.springframework.boot.SpringApplication","thread_name":"main","level":"ERROR","level_value":40000,"stack_trace":"org.apache.camel.FailedToStartRouteException:
Failed to start route SMS_JSON_MsgFlow because of Multiple consumers for the same endpoint is not allowed: jetty:http://0.0.0.0:7806/esb00/helmjson?httpMethodRestrict=POST&matchOnUriPrefix=true\r\n\tat
org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRouteConsumers(InternalRouteStartupManager.java:357)\r\n\tat
org.apache.camel.impl.engine.InternalRouteStartupManager.doStartRouteConsumers(InternalRouteStartupManager.java:319)\r\n\tat
org.apache.camel.impl.engine.InternalRouteStartupManager.safelyStartRouteServices(InternalRouteStartupManager.java:213)\r\n\tat
org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRoutes(InternalRouteStartupManager.java:147)\r\n\tat org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:3434)\r\n\tat
org.apache.camel.impl.engine.AbstractCamelContext.doStartContext(AbstractCamelContext.java:3103)\r\n\tat org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:3058)\r\n\tat
org.apache.camel.spring.boot.SpringBootCamelContext.doStart(SpringBootCamelContext.java:43)\r\n\tat org.apache.camel.support.service.BaseService.start(BaseService.java:119)\r\n\tat
org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2707)\r\n\tat org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262)\r\n\tat
org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:119)\r\n\tat org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:151)\r\n\tat
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)\r\n\tat
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)\r\n\tat
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)\r\n\tat
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)\r\n\tat
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)\r\n\tat
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:940)\r\n\tat
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)\r\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)\r\n\tat
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:307)\r\n\tat
org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)\r\n\tat
com.mbfscn.esb.runtime.MiniESBApplication.main(MiniESBApplication.java:16)\r\n"}
---
References:
[1]https://camel.apache.org/manual/route-policy.html
BRs.
Yainsun
[https://camel.apache.org/_/img/logo-d-f21b25ba38.svg]<https://camel.apache.org/manual/route-policy.html>
RoutePolicy<https://camel.apache.org/manual/route-policy.html>
Camel is an open source integration framework that empowers you to quickly and
easily integrate various systems consuming or producing data.
camel.apache.org