Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-15568

Dynamic route updates causes few requests to fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Not A Problem
    • 3.2.0
    • None
    • came-core
    • None
    • Unknown

    Description

      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:

      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);
              }
      
          }
      }
      
      

       

       

      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. 

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            patelminalb@gmail.com Minal Bhalodi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: