10

Currently my quartz job is triggered in this way:

  • When first schedule the job, the job will be triggered after 5 mins.
  • The job will be triggered 5 times, with the time interval 2 mins.

So if I schedule my job at time1, the job will be executed at time1 + 5, time1 + 7, time1 + 9, time1 + 11, time1 + 13

  private org.quartz.Trigger makeTrigger() {
    org.quartz.ScheduleBuilder<org.quartz.SimpleTrigger> scheduleBuilder =
        org.quartz.SimpleScheduleBuilder.simpleSchedule()
            .withIntervalInMilliseconds(intervalMillis)
            .withRepeatCount(repeatCount);

    return org.quartz.TriggerBuilder.newTrigger()
        .withIdentity(key.getLeft(), key.getRight())
        .usingJobData(new org.quartz.JobDataMap(jobData))
        .startAt(dateTimeHelper.toStandardDate(startDateTime))
        .withSchedule(scheduleBuilder)
        .build();
  }

But I need to let the job be less aggressive, so my question is how to set the triggers to have exponential time intervals? So that after I schedule the job at time1, the job will be executed at: time1 + 5, time1 + 7, time1 + 11, time1 + 19, time1 + 35?

Should I reschedule the job every time the job is finished?

Freya Ren
  • 2,086
  • 6
  • 29
  • 39

0 Answers0