What is the exact use of "period" and "fixedRate" together ? does it really make sense because if i specified the "period" value then anyways timer will trigger after that interval. So what is the exact use of "fixedRate" flag?
I am confused please help me out !
The Timer component is used to generate message exchanges when a timer fires. You can only consume events from this endpoint.
The Bean EIP is used for invoking a method on a bean, and the returned value is the new message body. The Bean EIP is similar to the Bean component which also is used for invoking beans, but in the form as a Camel component.
The Direct component provides direct, synchronous invocation of any consumers when a producer sends a message exchange. This endpoint can be used to connect existing routes in the same camel context.
You can read the javadoc api of the java.util.Timer at: http://docs.oracle.com/javase/7/docs/api/java/util/Timer.html
They explain the difference between fixed rate and delayed.
The Camel Timer Endpoint uses java.util.Timer
.
If you set the fixedRate
flag to true
the following method is used :
java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, java.util.Date, long)
Otherwise the following method is used :
java.util.Timer#schedule(java.util.TimerTask, java.util.Date, long)
If I understand the Javadoc of the Timer class a fixed-rate execution does not care about the execution time of the previous execution, only of the initial execution.
An example to clarify :
Take a timer with a fixed-rate execution with an initial execution at 12:00 and a period of 1 hour. The timer will (try to) start a third execution at 14:00 - even if, for some reason, the execution which should have started at 13:00 was delayed and actually started at 13:06.
If the timer did not have a fixed-rate execution it would (try to) start the third execution at 14:06.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With