Hi, We are using Apache Camel 3.2.0. We update camel routes at runtime using below code.
Problem Statement: Dynamic routes updates makes few requests to fail at runtime. When these routes are being updated, we also serve requests using those routes from same CamelContext and few Requests fails. Since there can be only one CamelContext per Application, I am not sure how can I resolve this issue. My application’s code to update routes at runtime: ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class); // camelContext is autowired in the same class mcc.addRouteDefinitions(workflowDefinitionsList); // workflowDefinitionsList is the list of XML routes I want to load at runtime Here is camel 3 code for addRouteDefinitions method: Camel 3: public synchronized void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception { if (routeDefinitions != null && !routeDefinitions.isEmpty()) { List<RouteDefinition> list = new ArrayList(); routeDefinitions.forEach((r) -> { if (this.routeFilter == null || (Boolean)this.routeFilter.apply(r)) { list.add(r); } }); this.removeRouteDefinitions(list); this.routeDefinitions.addAll(list); if (this.shouldStartRoutes()) { ((ModelCamelContext)this.getCamelContext().adapt(ModelCamelContext.class)).startRouteDefinitions(list); } } } Please let me know if you need more information. Thanks, Minal