6

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 !

towi
  • 21,587
  • 28
  • 106
  • 187
user2606572
  • 61
  • 1
  • 2

2 Answers2

3

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.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
2

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.