camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: How to create a central route controller
Date Tue, 01 Jul 2014 19:29:58 GMT
Hi

Maybe check the control bus eip and component

On Tue, Jul 1, 2014 at 8:30 AM, dermoritz <tanteanni@hotmail.com> wrote:
> 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
> refactoring.
> 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
> method:
>
> /**
>  * Starts all routes found in context.
>  */
> public void startAll() {
>     log.info("starting all routes.");
>     for (RouteDefinition route : ((ModelCamelContext)
> context).getRouteDefinitions()) {
>         String id = route.getId();
>         try {
>             log.info("starting route " + id);
>             context.startRoute(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
> main-method:
>
>     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
>         SLF4JBridgeHandler.removeHandlersForRootLogger();
>         // redirects all java.util.logger stuff to slf4j
>         SLF4JBridgeHandler.install();
>         i.getInstance(RouteControl.class).startAll();
>         main.enableHangupSupport();
>         main.run();
>
>
>     }
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-create-a-central-route-controller-tp5753118.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Mime
View raw message