camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikaelfj <mikae...@gmail.com>
Subject Re: Scheduling routes with RoutePolicy
Date Mon, 04 Apr 2011 09:54:11 GMT
Hi,

I've been trying it out using the noAutoStartUp() - which seems to make it
work, i.e. let the route begin in a stopped state and then having a
cron-schedule to start it at a given point in time.

However, I need to have it to start and then stop a few hours later, but
this does not work.

If I set both a routeStartTime and a routeStopTime on the policy, then two
scheduled events are being handled, but they are both firing the STOP
action.

I've been through the code, and I think that the problem is in this method
of the ScheduledRoutePolicy:

protected void loadCallbackDataIntoSchedulerContext(Action action, Route
route) throws SchedulerException {
        getScheduler().getContext().put(SCHEDULED_ACTION, action);
        getScheduler().getContext().put(SCHEDULED_ROUTE, route);
    }    

This method is called during each invocation of the
ScheduledRoutepolicy.scheduleRoute(Action action) method - which in my test
gets called twice - first for the Start action and secondly for the Stop
action.

So after the second invocation of loadCallbackDataIntoSchedulerContext the
SCHEDULED_ACTION on the context is the Stop action - even though I wanted to
define both a Start and Stop action.

I.e. it is possible to register in the routepolicy multiple actions, but the
registration in the scheduler context only allows for one single action.

Is this deliberate or is it a flaw in the implementation.

>From comments on other issues in the forum I can see that it should be
possible to register multiple policies on a route from Camel 2.7 - however,
we are currently stuck on JDK1.5 so Camel 2.7 is not an option for us.

Regards
Mikael

--
View this message in context: http://camel.465427.n5.nabble.com/Scheduling-routes-with-RoutePolicy-tp4269200p4281413.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message