public void execute(JobExecutionContext context) throws JobExecutionException {
String jobName = context.getJobDetail().getFullName();
_log.info("---" + jobName + " executing at " + new Date());
// a contrived example of an exception that
// will be generated by this job due to a
// divide by zero error
try {
int zero = 0;
int calculation = 4815 / zero;
} catch (Exception e) {
_log.info("--- Error in job!");
JobExecutionException e2 =
new JobExecutionException(e);
// Quartz will automatically unschedule
// all triggers associated with this job
// so that it does not run again
e2.setUnscheduleAllTriggers(true);
throw e2;
}
_log.info("---" + jobName + " completed at " + new Date());
}
|