How to schedule Camel route to run once a day.

Solution Verified - Updated -

Environment

  • Red Hat JBoss Fuse
    • 6.2.1

Issue

  • if suppose we want Camel route to be executed at a particular time like HH:MM:SS daily instead of every 5 seconds
  <camelContext xmlns="http://camel.apache.org/schema/blueprint">
    <route id="timerToLog">
      <from uri="timer:foo?period=5000"/>
      <setBody>
          <method ref="helloBean" method="hello"/>
      </setBody>
      <log message="The message contains ${body}"/>
      <to uri="mock:result"/>
    </route>
  </camelContext>

Resolution

  • Use Camel Quartz component to schedule the Camel route to run once a day. Quartz supports Cron-like expressions for specifying timers in a handy format. Click here more details.

  • For example,the following will fire at 4pm every Monday, Tuesday, Wednesday, Thursday and Friday i.e weekdays,

<from uri="quartz://myTimerName?cron=0+0+16+?+*+MON-FRI" />

For more details on the Cron expressions, click here

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.