camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dermoritz <>
Subject How to create a central route controller
Date Tue, 01 Jul 2014 06:30:17 GMT
in my java based camel app i want create a central class that controls all
routes (starting, stopping) but i don't want any route be aware of this
class. routes should keep untouched on any changes of route control, like
My app uses guice (DI) and at the moment i began with a simple class
RouteControl that has one method and injects the camel context. here is the

 * Starts all routes found in context.
public void startAll() {"starting all routes.");
    for (RouteDefinition route : ((ModelCamelContext)
context).getRouteDefinitions()) {
        String id = route.getId();
        try {
  "starting route " + id);
        } catch (Exception e) {
            throw new IllegalStateException("Unable to start route " + id +
" cause, ", e);

The problem is that is not working. On log i see "starting route" for each
route but then "DefaultCamelContext            INFO  Total 2 routes, of
which 0 is started."

I am unsure if the method is wrong or how it is invoked. here is my

    public static void main(final String... args) throws Exception {
        Injector i;
        if (args.length < 1 || Strings.isNullOrEmpty(args[0])) {
            i = Guice.createInjector(new CepModule());
        } else {
            i = Guice.createInjector(new CepModule(args[0]));
        OurMain main = i.getInstance(OurMain.class);
        // eliminates logging to java.util.logger
        // redirects all java.util.logger stuff to slf4j


View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message