Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
Quartz2 ComponentAvailable as of Camel 2.12.0 The quartz2: component provides a scheduled delivery of messages using the Quartz Scheduler 2.x . Maven users will need to add the following dependency to their <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-quartz2</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> NOTE: Quartz 2.x API is not compatible with Quartz 1.x. If you need to remain on old Quartz 1.x, please URI formatquartz2://timerName?options quartz2://groupName/timerName?options quartz2://groupName/timerName?cron=expression quartz2://timerName?cron=expression The component uses either a You can append query options to the URI in the following format, Options
For example, the following routing rule will fire two timer events to the from("quartz2://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=1").routeId("myRoute").to("mock:result"); When using Running in OSGi and having multiple bundles with quartz routes If you run in OSGi such as Apache ServiceMix, or Apache Karaf, and have multiple bundles with Camel routes that start from Quartz2 endpoints, then make sure if you assign Configuring quartz.properties fileBy default Quartz will look for a However the Camel Quartz2 component also allows you to configure properties:
To do this you can configure this in Spring XML as follows <bean id="quartz" class="org.apache.camel.component.quartz2.QuartzComponent"> <property name="propertiesFile" value="com/mycompany/myquartz.properties"/> </bean> Enabling Quartz scheduler in JMXYou need to configure the quartz scheduler properties to enable JMX. From Camel 2.13 onwards Camel will automatic set this option to true, unless explicit disabled. Starting the Quartz schedulerThe Quartz2 component offers an option to let the Quartz scheduler be started delayed, or not auto started at all.
To do this you can configure this in Spring XML as follows <bean id="quartz2" class="org.apache.camel.component.quartz2.QuartzComponent"> <property name="startDelayedSeconds" value="5"/> </bean> ClusteringIf you use Quartz in clustered mode, e.g. the Note: When running in clustered node no checking is done to ensure unique job name/group for endpoints. Message HeadersCamel adds the getters from the Quartz Execution Context as header values. The following headers are added: The Using Cron TriggersQuartz supports Cron-like expressions for specifying timers in a handy format. You can use these expressions in the For example, the following will fire a message every five minutes starting at 12pm (noon) to 6pm on weekdays: from("quartz2://myGroup/myTimerName?cron=0+0/5+12-18+?+*+MON-FRI").to("activemq:Totally.Rocks"); which is equivalent to using the cron expression 0 0/5 12-18 ? * MON-FRI The following table shows the URI character encodings we use to preserve valid URI syntax:
Specifying time zoneThe Quartz Scheduler allows you to configure time zone per trigger. For example to use a timezone of your country, then you can do as follows: quartz2://groupName/timerName?cron=0+0/5+12-18+?+*+MON-FRI&trigger.timeZone=Europe/Stockholm The timeZone value is the values accepted by Using QuartzScheduledPollConsumerSchedulerThe Quartz2 component provides a Polling Consumer scheduler which allows to use cron based scheduling for Polling Consumer such as the File and FTP consumers. For example to use a cron based expression to poll for files every 2nd second, then a Camel route can be define simply as: from("file:inbox?scheduler=quartz2&scheduler.cron=0/2+*+*+*+*+?") .to("bean:process"); Notice we define the The following options is supported:
Important: Remember configuring these options from the endpoint URIs must be prefixed with from("file:inbox?scheduler=quartz2&scheduler.cron=0/2+*+*+*+*+?&scheduler.triggerId=myId&scheduler.triggerGroup=myGroup") .to("bean:process"); There is also a CRON scheduler in Spring, so you can use the following as well: from("file:inbox?scheduler=spring&scheduler.cron=0/2+*+*+*+*+?") .to("bean:process"); |