You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by pokkie <iz...@gmail.com> on 2013/04/16 16:52:25 UTC
CronScheduledRoutePolicy example
Hi,
I am looking at the CronScheduledRoutePolicy that is published on the Camel
Website.
It has the following code snippet:
CronScheduledRoutePolicy startPolicy = new CronScheduledRoutePolicy();
startPolicy.setRouteStartTime("*/3 * * * * ?");
from("direct:start")
.routeId("testRoute").routePolicy(startPolicy).noAutoStartup()
.to("mock:success");
What exactly does the */3 represent in the above example?
Does it mean that the route will be started every 3 minutes? I am asking
because when I run my example the route is continuously being executed.
For completeness here is my code:
public static void main(String[] args)
{
CamelContext camelContext = new DefaultCamelContext();
try
{
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
CronScheduledRoutePolicy startPolicy = new
CronScheduledRoutePolicy();
startPolicy.setRouteStartTime("*/3 * * * * ?");
from("file:data/inbox?noop=true")
.routePolicy(startPolicy).noAutoStartup()
.to("file:/media/dhd03656/Backup/sharenet");
}
});
camelContext.start();
Thread.sleep(1000000);
camelContext.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
--
View this message in context: http://camel.465427.n5.nabble.com/CronScheduledRoutePolicy-example-tp5730978.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: CronScheduledRoutePolicy example
Posted by pokkie <iz...@gmail.com>.
Thanks Magnus. All sorted now :)
--
View this message in context: http://camel.465427.n5.nabble.com/CronScheduledRoutePolicy-example-tp5730978p5731055.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: CronScheduledRoutePolicy example
Posted by Magnus Palmér <ma...@gmail.com>.
It is a Quartz cron expression, you can read about it here:
http://quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
Normally you wouldn't use * with /, but I guess that works as well.
In your configuration it will start every 3 seconds.
2013/4/16 pokkie <iz...@gmail.com>
> Hi,
>
> I am looking at the CronScheduledRoutePolicy that is published on the Camel
> Website.
>
> It has the following code snippet:
>
> CronScheduledRoutePolicy startPolicy = new CronScheduledRoutePolicy();
> startPolicy.setRouteStartTime("*/3 * * * * ?");
>
> from("direct:start")
> .routeId("testRoute").routePolicy(startPolicy).noAutoStartup()
> .to("mock:success");
>
> What exactly does the */3 represent in the above example?
>
> Does it mean that the route will be started every 3 minutes? I am asking
> because when I run my example the route is continuously being executed.
>
> For completeness here is my code:
>
> public static void main(String[] args)
> {
> CamelContext camelContext = new DefaultCamelContext();
>
> try
> {
> camelContext.addRoutes(new RouteBuilder() {
> @Override
> public void configure() throws Exception {
>
> CronScheduledRoutePolicy startPolicy = new
> CronScheduledRoutePolicy();
> startPolicy.setRouteStartTime("*/3 * * * * ?");
>
> from("file:data/inbox?noop=true")
> .routePolicy(startPolicy).noAutoStartup()
> .to("file:/media/dhd03656/Backup/sharenet");
> }
> });
>
> camelContext.start();
> Thread.sleep(1000000);
> camelContext.stop();
>
> } catch (Exception e) {
> e.printStackTrace();
> }
>
>
> }
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/CronScheduledRoutePolicy-example-tp5730978.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Brgds, Magnus Palmér
+46736845680