- 於public void execute(JobExecutionContext arg0) throws JobExecutionException自行拋出JobExecutionException
- 將欲拋出的JobExecutionException設定為setUnscheduleAllTriggers(true)
- throw JobExecutionException
@Override public void execute(JobExecutionContext arg0) throws JobExecutionException { //do something... 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; } }
參考:Example - Dealing with Job Exceptions
沒有留言:
張貼留言