Apache Camel 2.12 - Even easier cron scheduled routes

In the upcoming Apache Camel 2.12 we have recently introduced a SPI that allows to plugin different schedulers for scheduled based consumers.

So the motivation is that some Camel components has scheduled consumers, most know is the file and ftp consumers. By default they use the scheduler from the JVM that can schedule based on a fixed period. Though with the SPI we now allows a different scheduler to be used instead.

We have two cron based schedulers ready out of the box in the camel-quartz2 and camel-spring components. So you pick you favorite, or dive in and build your own scheduler.

CRON expression
So if you want to pickup files during working hours (polling every 10th second) on weekdays you can easily do this now (notice we use + as space separator)

... with Spring

<from uri="file:inbox?scheduler=spring&scheduler.cron=0/10+6-18+*+*+MON-FRI"/>

... with Quartz

<from uri="file:inbox?scheduler=quartz2&scheduler.cron=0/10+6-18+*+*+MON-FRI"/>

In older releases of Camel you would need to sort to use a route policy, to implement a similar solution. There is a cron based route policy that can be used to setup cron expressions when a route should be started, and when it should be stopped. Though with this new functionality in Camel 2.12, its even easier to just define the cron expression in the endpoint uri directly.

There is more details in the Camel docs at

And yeah camel-quartz2 is also a new component in the upcoming Apache Camel 2.12 release. In fact we have already 14 new components. You can peak at the work in progress release notes to see what is coming down the road.


satya said...

Is it possible to configure multiple cron expressions say
"0+0+6+?+*+2-6" and
"0+15+10+?+*+2-6" ?

Claus Ibsen said...

You can do only 1 cron expression, but its usually very flexible so you can do something a like 0+0/15+6/10+?+*+2-6 etc.

Though can't remember if its 0/15 or 0-15 but you can find information on the internet how the syntax is.

satya said...

Yes we can have 0+0,15+6,10+?+*+2-6.But the problem is this will be applicable for : 6AM, 6:15AM,10AM and 10:15 AM.

I need for only 6AM and 10:15 AM.We cant assign specific minute for every hour. Please suggest.


Unknown said...
This comment has been removed by the author.
Unknown said...


I am trying to use DSL and configure Quartz2 component to run a route once every hour with following requirements,

1) If the container is down for some reason and if it comes up after scheduled time, the job should run before the next scheduled time

2) If the job is over running, I do not want an another instance to be started

I tried following options and the job is not able to meet the 1st requirement,


Appreciate if you could help me resolve this.


Unknown said...

HI, I'm trying to integrate camel quartz scheduler to REST web service and able to integrate.

Only problem i am facing here is , I am unable to change the cron expression at run time.
So, please help me in changing the cron expression at run time via API

Unknown said...

Can I use the scheduler component with the FTP/SFTP Component ?

Could you please provide an example ?

Unknown said...

Can I use the scheduler component with the FTP/SFTP Component ?

Could you please provide an example

rev said...

From the above comments i understood that we cannot add multiple cron expressions? IS there any support to do it in one single expression?

For eg: I want a job to run at 3:15 pm, 4:00 pm, 5:20 pm.

Claus Ibsen said...

No you cannot do that.