Timer Options :
in the previous post "Camel - Timer 1" , we explored two options , delay and period where delay is tell the timer how much to wait until fire first event , and period option tell the timer the interval between each event in millisecond.
there are another two nice options : time and repeatCount.
Say you want the following scenario , at date time 20-12-2012 20:12:3 you want the timer to fire 3 times and each time generate hello world message ( as used in the previous example )
CamelContext ctx = new DefaultCamelContext();
ctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("timer://Demo2Timer?period=1000&repeatCount=3&time=2012-12-20 20:12:03").
setBody().simple("Hello World :) ")
.to("stream:out");
}
});
ctx.start();
Thread.sleep(999999);
ctx.stop();
running this example will generate 3 events ( repeatCount=3) that first event fired at our specified date ( time=2012-12-20 20:12:03) and between each one timer period one second ( period = 1000 )
in the previous post "Camel - Timer 1" , we explored two options , delay and period where delay is tell the timer how much to wait until fire first event , and period option tell the timer the interval between each event in millisecond.
there are another two nice options : time and repeatCount.
Say you want the following scenario , at date time 20-12-2012 20:12:3 you want the timer to fire 3 times and each time generate hello world message ( as used in the previous example )
CamelContext ctx = new DefaultCamelContext();
ctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("timer://Demo2Timer?period=1000&repeatCount=3&time=2012-12-20 20:12:03").
setBody().simple("Hello World :) ")
.to("stream:out");
}
});
ctx.start();
Thread.sleep(999999);
ctx.stop();
running this example will generate 3 events ( repeatCount=3) that first event fired at our specified date ( time=2012-12-20 20:12:03) and between each one timer period one second ( period = 1000 )
No comments:
Post a Comment