Search code examples
javajbossquartz-schedulerseamcronexpression

Seam Quartz Dispatcher not firing on seconds and minutes field for a given cron expression


I have a Quartz job that is to fire for a certain time repeatedly. Unfortunately it does not fire for some unknown reasons.

Here is my cron expression :

0/5 0 0 * * ?

So basically the job should be fired every 5 seconds. This is the part which does not work.

Now the wierd thing is when I changed the cron expression to

0 0 0/1 * * ?

which fire the job at every 1 hour. The job is fired and I can see that the method is being invoked on the Java side.

I have tried also on the minute field eg. 0 0/5 0 * * ? for every 5 minutes but it does not fire either.

I don't know what is the behavior is that the other two expression are not firing. Any help would be very much appreciated.

Here is also my seam.quartz.properties file

Configure Main Scheduler Properties

org.quartz.scheduler.instanceName QuartzScheduler
org.quartz.scheduler.instanceId AUTO
org.quartz.scheduler.rmi.export false
org.quartz.scheduler.rmi.proxy false

Configure ThreadPool

org.quartz.threadPool.class org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount 10

Configure JobStore

org.quartz.jobStore.misfireThreshold 60000
org.quartz.jobStore.class org.quartz.simpl.RAMJobStore

I am using Jboss 5.1.0, Seam 2.2 and Quartz 1.8.3.


Solution

  • 0/5 0 0 * * ?
    

    The above cron expression will schedule the job to trigger every 5 seconds during minute 0 and hour 0 daily. In other words, the first minute every day, the job will execute 12 times.

    I assume you want it to trigger any hour, that is every 5 seconds regardless of the hour.

    Replace the two zeros indicating minute and hour with the * wildcard. Also, you don't need ? which means no specific value. The below expression will schedule the timer every 5 seconds, regardless of which hour or minute it is:

    0/5 * * * * *
    

    The reason why 0 0 0/1 * * ? is "working" is because you undertand the expression correctly, which you didn't with the ones that were "not working". Basically it means every 1 hour at the start of a new hour (minute 0 and second 0).

    This documentation is an excellent resource with examples for Quartz 1.X:

    http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger