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); } |