Search code examples
javacronapache-camelquartz-schedulerjob-scheduling

Apache Camel Schedule multiple times a day


I have to execute/run same task in different fixed times every day. The intervals between the time is not same.

for example I want to run a router 05:30, 11:30, 15:00, 21:00.

I got lot of apache camel example with scheduler, quartz. But all are with static time interval or only one time configurable.

Is there way to configure in apache camel ?


Solution

  • Try something like this:

    <route>
      <from uri="quartz2://timer1?cron=0+30+5+*+*+*">
      <from uri="quartz2://timer2?cron=0+30+11+*+*+*">
      <from uri="quartz2://timer3?cron=0+00+15+*+*+*">
      <from uri="quartz2://timer4?cron=0+00+21+*+*+*">
      <to uri="...">
    </route>
    

    It's not possible today in the quartz component to provide a custom trigger, and the quartz cron trigger didn't support what you want. Just create a route with multiple consumers.