Hello, We are upgrading from Camel 3.18.4 to 3.22.4 to pickup some important bug fixes but noticed a new problem. When we are instantiating a route in a spring-boot (2.6.2) app from a route-template the Java builder intermittently fails 3 out of 4 times. As a workaround we switched to using the Java DSL way to create the route and this seems to work fine.
This Java DSL code works: final TemplatedRouteDefinition route = templatedRoute("template1") .routeId("route-template1-id") .parameter("param1", queueName) .parameter("param2", restApiEndpoint)); LOG.info("buildTemplatedRoute() created templated route: {}", route.getRouteId()); But this Java builder code fails intermittently (3 out of 4 times): final String route = TemplatedRouteBuilder.builder(camelContext, "template1") .routeId("route-template1-id") .parameter("param1", queueName) .parameter("param2", restApiEndpoint) .add(); LOG.application.info("buildTemplatedRoute() created templated route: {}", route); When the service starts and calls the Camel 3.22.4 builder code, it fails and throws this: org.apache.camel.spring.boot.CamelSpringBootInitializationException: java.lang.IllegalArgumentException: Cannot find RouteTemplate with id template1 at org.apache.camel.spring.boot.CamelSpringBootApplicationListener.onApplicationEvent(CamelSpringBootApplicationListener.java:212) ~[camel-spring-boot-3.22.4.jar:3.22.4] at org.apache.camel.spring.boot.CamelSpringBootApplicationListener.onApplicationEvent(CamelSpringBootApplicationListener.java:58) ~[camel-spring-boot-3.22.4.jar:3.22.4] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.14.jar:5.3.14] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.14.jar:5.3.14] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.14.jar:5.3.14] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.14.jar:5.3.14] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.14.jar:5.3.14] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) ~[spring-context-5.3.14.jar:5.3.14] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.14.jar:5.3.14] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.2.jar:2.6.2] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-2.6.2.jar:2.6.2] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.6.2.jar:2.6.2] at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.2.jar:2.6.2] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.2.jar:2.6.2] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.2.jar:2.6.2] at ca.gc.esdc.interop.interfaces.cancelled_payments.payment.sps_f2r_ent.service.SpsMessageProcessorApplication.main(SpsMessageProcessorApplication.java:25) ~[classes/:na] Caused by: java.lang.IllegalArgumentException: Cannot find RouteTemplate with id ConsumerRouteDefaultTemplate at org.apache.camel.impl.DefaultModel.addRouteFromTemplate(DefaultModel.java:419) ~[camel-core-engine-3.22.4.jar:3.22.4] at org.apache.camel.impl.DefaultCamelContext.addRouteFromTemplate(DefaultCamelContext.java:502) ~[camel-core-engine-3.22.4.jar:3.22.4] at org.apache.camel.builder.TemplatedRouteBuilder.add(TemplatedRouteBuilder.java:179) ~[camel-core-model-3.22.4.jar:3.22.4] at ca.gc.esdc.interop.interfaces.cancelled_payments.payment.sps_f2r_ent.service.routes.SpsMessageProcessorRoute.buildTemplatedRoute(SpsMessageProcessorRoute.java:91) ~[classes/:na] at ca.gc.esdc.interop.interfaces.cancelled_payments.payment.sps_f2r_ent.service.routes.SpsMessageProcessorRoute.defineRoutes(SpsMessageProcessorRoute.java:59) ~[classes/:na] at ca.gc.esdc.interop.base.messageprocessor.routes.AbstractRoute.configure(AbstractRoute.java:38) ~[base-message-processor-1.3.0-DAN.jar:na] at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:723) ~[camel-core-model-3.22.4.jar:3.22.4] at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:668) ~[camel-core-model-3.22.4.jar:3.22.4] at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:600) ~[camel-core-model-3.22.4.jar:3.22.4] at org.apache.camel.impl.engine.AbstractCamelContext.addRoutes(AbstractCamelContext.java:1212) ~[camel-base-engine-3.22.4.jar:3.22.4] at org.apache.camel.main.RoutesConfigurer.addDiscoveredRoutes(RoutesConfigurer.java:247) ~[camel-main-3.22.4.jar:3.22.4] at org.apache.camel.main.RoutesConfigurer.configureRoutes(RoutesConfigurer.java:222) ~[camel-main-3.22.4.jar:3.22.4] at org.apache.camel.spring.boot.CamelSpringBootApplicationListener.onApplicationEvent(CamelSpringBootApplicationListener.java:106) ~[camel-spring-boot-3.22.4.jar:3.22.4] So it appears that there is some timing issue that makes this fail intermittently since the template cannot be found. One extra complication is that we have coded the route-template definitions in a dependent jar that is pulled into our spring-boot service by our maven build. So the code that actually builds and runs the route is in the service. We added this to our service main class in order to find the route in the dependent jar: @ComponentScan(basePackages = { "package-for-the-dependent-jar", "package-for-the-spring-boot-service" // must be after the dep. jar package }) Wonder if what we see now with the builder is a known problem in Camel 3.22.4 ? Any comments/thoughts? Thanks, ...jvh