[ https://issues.apache.org/jira/browse/CAMEL-15568?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Minal Bhalodi updated CAMEL-15568: ---------------------------------- Component/s: (was: camel-core) camel-core-engine > Dynamic route updates causes few requests to fails > --------------------------------------------------- > > Key: CAMEL-15568 > URL: https://issues.apache.org/jira/browse/CAMEL-15568 > Project: Camel > Issue Type: Bug > Components: camel-core-engine > Affects Versions: 3.2.0 > Reporter: Minal Bhalodi > Priority: Minor > > We are using Apache Camel 3.2.0. We update camel routes at runtime using > below code. > // update routes in camel contexts. Definitions are in XML files > ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class); > mcc.addRouteDefinitions({{workflowDefinitionsList}}); {{// > workflowDefinitionsList is the list of XML routes}} > > *Problem Statement*: Dynamic routes updates causes few requests to fail at > runtime. When these routes are being updated, we also call getRoute to serve > live traffic. > Since addRouteDefinitions first delete routes given in > {{workflowDefinitionsList}} from camel context and then add those routes back > to camelcontext, These routes won't be available for few mili second and that > causes request to fails. > Route route = exchange.getContext().getRoute(workflowRouteId); // get route > Since there can be only one CamelContext per Application, I am not sure how > can I resolve this issue. Is there any other method available where we can > PATCH routes changes at runtime. Dynamic route updates shouldn't cause few > requests to fails. > > > {{Here is camel 3 code for addRouteDefinitions method where routes are being > removed and added:}} > {code:java} > 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); > } > } > } > {code} > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005)