Tag: Quartz

25 July

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…


26 April

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:
  1. public void resetScheduleJob() throws CustomSystemException {
  2.  
  3.       StdScheduler scheduler = (StdScheduler)MyQueueContext.getContext().getBean("scheduler");
  4.  
  5.       CronTriggerBean trigger = (CronTriggerBean)MyQueueContext.getContext().getBean("batchProducerTrigger");
  6.  
  7.       try {
  8.            trigger.setCronExpression(getCronExpression());
  9.  
  10.            scheduler.scheduleJob(trigger.getJobDetail(), trigger);
  11.  
  12.       } catch (ParseException pe) {
  13.          throw new CustomSystemException (pe);
  14.       } catch (SchedulerException se) {
  15.          throw new CustomSystemException (se);
  16.       }
  17.       LOG.info("Next run will be at: " + trigger.getNextFireTime());
  18.    }
  19. }
  20. private String getCronExpression() {
  21.  
  22.       // Small trick to get the hours of the day correct.
  23.       String hours = null;
  24.       if (startTime> endTime) {
  25.          hours = endTime + "-23,0-" + startTime;
  26.       } else if (startTime <endTime) {
  27.          hours = startTime + "-" + endTime;
  28.       } else {
  29.          hours = "0";
  30.       }
  31.       return "0 0/" + interval + " " + hours + " ? * " + days;
  32.    }


Continue reading...