1

I am building an apache camel application. I am pushing the routes through api like so

RouteBuilder routeBuilder = new RouteBuilder () {
        @Override
        public void configure() throws Exception {
            from ("file-watch://" + path)
                    .id (id)
                    .process (new FileChangeStarterExecutionProcessor ())
                    .noDelayer ()
                    .onException (Exception.class).handled (true)
                    .log (LoggingLevel.WARN, "Unable to watch directory exception ${exception.message}");
        }
    };

    try {
        context.addRoutes (routeBuilder);
        startRoute(id);
    } catch (Exception e) {
        e.printStackTrace ();
        log.error ("Can't submit route with id {} exception occurred {}", id, e.getMessage ());
    }

But this addRoutes method takes a lot of time around 4 minutes then I call start route on SpringBootCamelContext startRoute(id).

Can anyone please help me on this ?

Amit Mishra
  • 498
  • 5
  • 16
  • I am guessing you want to add routes to camel context while it's running? Do you have `autoStartup="false"` set somewhere? If not then Camel should start all added routes automatically. Also instead of `.id(id)` you should use `.routeId(id)` if you want to give your route specific id. – Pasi Österman Sep 19 '22 at 10:20
  • Yes, I want to add routes while CamelContext is running. Do you mean `autoStartup` within camel context or route ? – Amit Mishra Sep 19 '22 at 17:27
  • What happens is, when I add a route the `addRoutes(RouteBuilder r)` method takes a lot of time to finish the execution and routes are then started after sometime. Do you know is there is a delay or something blocks `addRoute` method for sometime ? – Amit Mishra Sep 19 '22 at 17:28
  • Well tried to replicate this with simple camel-main project using file-watch but startRoute call was pretty much instantaneous and routes that where added runtime started automatically. Maybe you're trying to use file-watch on slow network drive which could cause the issue? – Pasi Österman Sep 20 '22 at 07:30
  • Does it start quickly as you add it ? I found out that our components were starting instantly but file-watch take some time to start. – Amit Mishra Sep 20 '22 at 09:14
  • The method call to addRoute(FileWatchRoute) takes some time to finish adding it. I am running this on windows. Did you try that on linux ? – Amit Mishra Sep 20 '22 at 09:16
  • Managed to replicate the issue with Camel versions **3.18.2**, **3.14.5**, **3.11.7** but not with **3.7.7** or **3.4.4**. The culprit is the buggy file-watch-component not the `startRoute` or `addRoutes` methods. Maybe checkout if there are tickets and workarounds for this in [Apache jira](https://issues.apache.org/jira/projects/CAMEL/issues/CAMEL-18506?filter=allopenissues) if not then submit your own. – Pasi Österman Sep 20 '22 at 10:12
  • Yeah, because with other components it works fine – Amit Mishra Sep 20 '22 at 10:41

0 Answers0