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.
Continue reading…
Just a small post about something I noticed in Quartz. I wanted to offer the user a screen with functionality so they could (re)schedule a batch job which then would do all kinds of batch stuf. To schedule the job in my application I used the following Java code:
JAVA:
-
public void resetScheduleJob() throws CustomSystemException {
-
-
StdScheduler scheduler = (StdScheduler)MyQueueContext.getContext().getBean("scheduler");
-
-
CronTriggerBean trigger = (CronTriggerBean)MyQueueContext.getContext().getBean("batchProducerTrigger");
-
-
try {
-
trigger.setCronExpression(getCronExpression());
-
-
scheduler.scheduleJob(trigger.getJobDetail(), trigger);
-
-
-
throw new CustomSystemException (pe);
-
} catch (SchedulerException se) {
-
throw new CustomSystemException (se);
-
}
-
LOG.info("Next run will be at: " + trigger.getNextFireTime());
-
}
-
}
-
private String getCronExpression
() {
-
-
// Small trick to get the hours of the day correct.
-
-
if (startTime> endTime) {
-
hours = endTime + "-23,0-" + startTime;
-
} else if (startTime <endTime) {
-
hours = startTime + "-" + endTime;
-
} else {
-
hours = "0";
-
}
-
return "0 0/" + interval + " " + hours + " ? * " + days;
-
}
Continue reading...