I have searched for an answer on how to retrigger a job after a ceratin amount of time, if the job throws an exception. I cannot see any simple way of doing this.
if
// don't forget to use @PersistJobDataAfterExecution without it, the jobExecutionContext will reset the value of count.
SimpleTriggerImpl retryTrigger = new SimpleTriggerImpl();
retryTrigger.setName("jobname");
retryTrigger.setRepeatCount(0);
retryTrigger.setJobKey(jobExecutionContext.getJobDetail().getKey());
final Calendar cal = getCalendarInstance();
cal.add(Calendar.MINUTE, 1); //retry after one minute
retryTrigger.setStartTime(cal.getTime());
try {
jobExecutionContext.getScheduler().scheduleJob(retryTrigger); // schedule the trigger
} catch (SchedulerException ex) {
logger.error("something went wrong", ex);
}
JobExecutionException e2 = new JobExecutionException("retrying...");
e2.refireImmediately();
throw e2;