This example shows how to work with the Camel Timer component.
The Timer component is used to generate message exchanges when a timer fires. It’s useful for:
-
Polling resources at regular intervals
-
Scheduling batch jobs
-
Triggering periodic tasks
-
Creating heartbeat mechanisms
This example demonstrates various timer configurations including:
-
Simple periodic timer
-
Timer with initial delay
-
Timer with repeat count
-
Timer with fixed rate vs fixed delay
The example is minimal and shows how to use the timer component in standalone mode as a public static void main application.
To run the example type
$ mvn camel:runThe example will run for about 5 seconds demonstrating different timer patterns.
To stop the example hit ctrl+c
You can also run the example from your editor such as Eclipse, IDEA etc, by opening the class org.apache.camel.example.timer.TimerExample and then right click, and chose run java application.
The example shows multiple timer configurations:
-
timer:simple- Fires every 300ms -
timer:withDelay- Fires every 300ms after a 500ms initial delay -
timer:limited- Fires only 3 times with 100ms interval -
timer:fixedRate- Fires every 500ms at fixed rate regardless of processing time
If you hit any problem using Camel or have some feedback, then please let us know.
We also love contributors, so get involved :-)
The Camel riders!