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:

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….

if (job == null) {
    nextRun = scheduler.scheduleJob(trigger.getJobDetail(), trigger);
} else {
    scheduler.deleteJob(trigger.getJobDetail().getName(), trigger.getJobDetail().getGroup());
    nextRun = scheduler.scheduleJob(trigger.getJobDetail(), trigger);
}

About Pascal Alma

Pascal is a senior IT consultant and has been working in IT since 1997. He is monitoring the latest development in new technologies (Mobile, Cloud, Big Data) closely and particularly interested in Java open source tool stacks, cloud related technologies like AWS and mobile development like building iOS apps with Swift. Specialties: Java/JEE/Spring Amazon AWS API/REST Big Data Continuous Delivery Swift/iOS
This entry was posted in Spring Framework and tagged , . Bookmark the permalink.