[ https://issues.apache.org/jira/browse/CAMEL-15568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17200404#comment-17200404 ]
Minal Bhalodi commented on CAMEL-15568: --------------------------------------- [~bedla] Thanks for the quick response. I already posted on stack-overflow 5 days ago and also sent email in mailing list mentioned in the above link but didn't get any response so had to create this bug. [https://stackoverflow.com/questions/63931881/dynamic-routes-updates-issue-in-apache-camel] > 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} > > > We are not able to updates routes in camelcontext frequently because of this > issue. Everytime we update routes in camelcontext that causes us some FCI > since we have high traffic in our application. > -- This message was sent by Atlassian Jira (v8.3.4#803005)