QUARTZ

QUARTZ component

The QUARTZ component triggers messages using CRON-like expressions. It's more accurate than the default timer component. Learn how to work with the Quartz component.

The current version of camel only supports Quartz 1.x due to API change for Quartz 2.x.

How to use the QUARTZ component

Library

Create a new library with the following jars (in this order):

Camel version Library jars
2.18.3

See also  How to retrieve the Camel version of Decision Insight.

Routes

Now it's possible to create a route that uses this component. Here the definition of the route:

<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
  <route>
    <!-- Every 5 minutes -->
    <from uri="quartz://loop?cron=0+*/5+*+*+*+?" />
 
    <log message="processing ${header.fireTime}" />
    <to uri="mock:test" />
  </route>
</routes>


Timer name should be unique

The quartz timer name should be unique. You cannot have two routes with the same timer name.

In the following example, the node will fail to start both routes (only the first one will start) because the second route uses the same timer name as the first one (loop).

<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
  <route>
    <from uri="quartz://loop?cron=0+*/3+*+*+*+?" />
    <to uri="log:route1" />
  </route>
  <route>
    <from uri="quartz://loop?cron=0+*/7+*+*+*+?" />
    <to uri="log:route2" />
  </route>
</routes>

Here is the correct version:

<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
  <route>
    <from uri="quartz://loop1?cron=0+*/3+*+*+*+?" />
    <to uri="log:route1" />
  </route>
  <route>
    <from uri="quartz://loop2?cron=0+*/7+*+*+*+?" />
    <to uri="log:route2" />
  </route>
</routes>

Examples

Interval cron definition
Every minute
cron=0+*+*+*+*+?
Every 5 minutes
cron=0+*/5+*+*+*+?

Related Links