[CONF] Apache Camel: Quartz (page edited)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[CONF] Apache Camel: Quartz (page edited)

Dhiraj Bokde (Confluence)

Quartz has been edited by Hadrian Zbarcea (Jan 27, 2009).

(View changes)

Content:

Quartz Component

The quartz: component provides a scheduled delivery of messages using the Quartz scheduler.
Each endpoint represents a different timer (in Quartz terms, a Trigger and JobDetail).

URI format

quartz://timerName?parameters
quartz://groupName/timerName?parameters
quartz://groupName/timerName/cronExpression

You can configure the Trigger and JobDetail using the parameters (if not using cron expression)

Parameter Description
trigger.repeatCount How many times should the timer repeat for?
trigger.repeatInterval The amount of time in milliseconds between repeated triggers
job.name Sets the name of the job
stateful Uses a Quartz StatefulJob instead of the default Job

For example the following routing rule will fire 2 timer events to the endpoint mock:results

from("quartz://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=1").to("mock:result");

When using a StatefulJob the JobDataMap is re-persisted after every execution of the job, thus preserving state for the next execution.

Message Headers

Camel adds the getters from Quartz Execution Context as header values. These headers is added:
calendar, fireTime, jobDetail, jobInstance, jobRuntTime, mergedJobDataMap, nextFireTime, previousFireTime, refireCount, result, scheduledFireTime, scheduler, trigger, triggerName, triggerGroup.

The fireTime header contains the java.util.Date for when the exchange was fired.

Using Cron Triggers

Quartz supports Cron-like expressions for specifying timers in a handy format. You can use these expressions in the URI; though to preserve valid URI encoding we allow / to be used instead of spaces and $ to be used instead of ?.

For example the following will fire a message at 12pm (noon) every day

from("quartz://myGroup/myTimerName/0/0/12/*/*/$").to("activemq:Totally.Rocks");

which is equivalent to using the cron expression

0 0 12 * * ?

The following table shows the URI character encodings we use to preserve valid URI syntax

URI Character Cron character
'/' ' '
'$' '?'

See Also