camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikaelfj <mikae...@gmail.com>
Subject Scheduling routes with RoutePolicy
Date Tue, 29 Mar 2011 11:21:17 GMT
Hi,

I'm in the process of using CronScheduledRoutePolicy to schedule a route to
start and stop - i.e. to only be polling the from endpoint in a certain
time-interval - e.g. the below should ensure it only polls the from endpoint
one hour each day between 16-17:

CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
policy.setRouteStartTime("0 0 16 ? * *");
policy.setRouteStopTime("0 0 17 ? * *");
from(...)
.routeId(routeId)
.routePolicy(policy)
.process(...) 

As far as I can tell from my test, the setting of the routePolicy does not
automatically ensure that the route is stopped when I e.g. start the route,
say, at 11.
So I assume that the routePolicy just ensures that it will trigger at start
at 16 and a stop at 17 - but I need to ensure manually that if started at 11
it is initially in the stopped state - is that correctly understood?

We are building our routes inside an implementation of the
RouteBuilder.configure method e.g. like:

public void configure() throws Exception {
  CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
  policy.setRouteStartTime("0 0 16 ? * *"); 
  policy.setRouteStopTime("0 0 17 ? * *");
  from(...)
  .routeId(routeId)
  .routePolicy(policy)
  .process(...) 
}

This is different from e.g. the unit tests that shows how to start the
context and then stop a route.
So, how do I, in the implementation of the RouteBuilder.configure method
ensure that the route is initially stopped if the route is about to be
startet at 11?

Regards
Mikael

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

Mime
View raw message