Weird Quartz scheduler behaviour

As I posted before here I am using Quartz scheduler to schedule some batch jobs. It seemed to work fine but now while we were testing our application it appeared Quartz was showing some weird behaviour. I have scheduled 3 jobs, each with it’s own trigger in one scheduler. However, 2 of the jobs are only triggered if the trigger of other remaining job has been fired before.
Of course I checked my configuration multiple times but I couldn’t find something wrong with it. After lots of testing and debugging I solved the issue by replacing the rescheduleJob() command with a simple deleteJob() and scheduleJob().

Here is the relevant original piece of code:

1
2
3
4
5
if (job == null) {
    nextRun = scheduler.scheduleJob(trigger.getJobDetail(), trigger);
} else {
    nextRun = scheduler.rescheduleJob(trigger.getFullName(), trigger.getGroup(), trigger);
}

After replacing this code with the next piece it worked fine again, although I cannot explain why….

1
2
3
4
5
6
if (job == null) {
    nextRun = scheduler.scheduleJob(trigger.getJobDetail(), trigger);
} else {
    scheduler.deleteJob(trigger.getJobDetail().getName(), trigger.getJobDetail().getGroup());
    nextRun = scheduler.scheduleJob(trigger.getJobDetail(), trigger);
}
tags: ,

About Pascal Alma

Pascal started as an Oracle Developer in 1997 and developed numerous applications with Oracle Designer/Developer and PL/SQL. Since 2001 Pascal becomes more and more active with the development of software at the Java/J2EE platform. Nowadays Pascal is a senior JEE Developer/ Architect and has a lot of experience with several open source initiatives/ frameworks especially within the Enterprise Integration area. Besides these technical skills Pascal is a big Scrum enthusiastic.

Comments are closed.