LibraryToggle FramesPrintFeedback
Name Default Value Description
time null A java.util.Date the first event should be generated. If using the URI, the pattern expected is: yyyy-MM-dd HH:mm:ss or yyyy-MM-dd'T'HH:mm:ss.
pattern null Allows you to specify a custom Date pattern to use for setting the time option using URI syntax.
period 1000 If greater than 0, generate periodic events every period milliseconds.
delay 0 The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the time option.
fixedRate false Events take place at approximately regular intervals, separated by the specified period.
daemon true Specifies whether or not the thread associated with the timer endpoint runs as a daemon.
repeatCount 0 Camel 2.8: Specifies a maximum limit of number of fires. So if you set it to 1, the timer will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever.

When the timer is fired, it adds the following information as properties to the Exchange:

Name Type Description
Exchange.TIMER_NAME String The value of the name option.
Exchange.TIMER_TIME Date The value of the time option.
Exchange.TIMER_PERIOD long The value of the period option.
Exchange.TIMER_FIRED_TIME Date The time when the consumer fired.
Exchange.TIMER_COUNTER Long Camel 2.8: The current fire counter. Starts from 1.

When the timer is fired, it adds the following information as headers to the IN message

Name Type Description
Exchange.TIMER_FIRED_TIME java.util.Date The time when the consumer fired

To set up a route that generates an event every 60 seconds:

   from("timer://foo?fixedRate=true&period=60000").to("bean:myBean?method=someMethodName");
[Tip]Tip

Instead of 60000 you can specify the more readable, period=60s.

The above route will generate an event and then invoke the someMethodName method on the bean called myBean in the Registry such as JNDI or Spring.

And the route in Spring DSL:

  <route>
    <from uri="timer://foo?fixedRate=true&eriod=60000"/>
    <to uri="bean:myBean?method=someMethodName"/>
    </route>
Comments powered by Disqus