camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dermoritz <tantea...@hotmail.com>
Subject How to implement special start up logic using RoutePolicyFactory
Date Fri, 21 Nov 2014 11:19:28 GMT
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.

Mime
View raw message