You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dermoritz <ta...@hotmail.com> on 2014/11/21 12:19:28 UTC

How to implement special start up logic using RoutePolicyFactory

I have a standalone guice camel app using CamelModul/GuiceCamelContext. Now i
need to implement a special start-up logic: If application is started make
sure that no route is started (set all to autostart false) but start 2
certain routes (from("sql...")). If both routes finished start all other
routes.

I don't want to add this logic to all routes individually but on a central
place. So the new RoutePolicyFactory came to mind. My problem is how to use
it correctly / where to add it to context.
Since i use Guice with camel module i "provide" a method that returns all
routbuilders. In my case i return a single route builder that is including
(includeRoutes(RouteBuilder)) other Routebuilders.

My problem is if i add the RoutePolicyFactory to constructor of this central
RouteBuilder "createRoutePolicy" is never called?! If i understood doc
correctly this method should be called for every route automatically?
This is the code adding the factory (within constructor of RouteBuilder):

        this.getContext().addRoutePolicyFactory(new RoutePolicyFactory() {

            @Override
            public RoutePolicy createRoutePolicy(CamelContext context,
String id, RouteDefinition route) {

                return new LookupRoutePolicy();
            }
        });





--
View this message in context: http://camel.465427.n5.nabble.com/How-to-implement-special-start-up-logic-using-RoutePolicyFactory-tp5759436.html
Sent from the Camel - Users mailing list archive at Nabble.com.