Quartz异常处理(Quartz exception handling)

我有以下石英工作。 我用它做了一些测试。

public void execute(JobExecutionContext context) throws JobExecutionException { try { Object result = callable.call(); } catch (Exception e) { JobExecutionException e2 = new JobExecutionException(e); if (REFIRE_IMMEDIATELY.equals(policy)) { e2.setRefireImmediately(true); } else if (UNSCHEDULE_ALL_TRIGGERS.equals(policy)) { e2.setUnscheduleAllTriggers(true); } else { e2.setUnscheduleFiringTrigger(true); } throw e2; } }

但我无法完全理解setUnscheduleAllTriggers setUnscheduleFiringTrigger 之间的区别 。 不幸的是,没有Javadoc。

有人可以帮助我吗?

谢谢

I have the following quartz job. I made some test with it.

public void execute(JobExecutionContext context) throws JobExecutionException { try { Object result = callable.call(); } catch (Exception e) { JobExecutionException e2 = new JobExecutionException(e); if (REFIRE_IMMEDIATELY.equals(policy)) { e2.setRefireImmediately(true); } else if (UNSCHEDULE_ALL_TRIGGERS.equals(policy)) { e2.setUnscheduleAllTriggers(true); } else { e2.setUnscheduleFiringTrigger(true); } throw e2; } }

But I can't fully understand what is the difference between setUnscheduleAllTriggers and setUnscheduleFiringTrigger. And unfortunately there is no Javadoc.

Does someone can help me ?

Thanks

最满意答案

在石英中,你可以有多个触发器解雇你的工作。 如果作业执行失败的原因是触发器中固有的,您可能希望取消计划该特定触发器。 这是我对setUnscheduleFiringTrigger(true)的理解。

如果问题在于作业本身而不是触发器,那么无论是谁或是什么启动它,它都会在每次执行时失败。 因此,为了避免多次执行失败的麻烦,只是因为不同的触发器触发了作业,您可以使用setUnscheduleAllTriggers(true)来取消调度触发此作业的所有触发器,从而防止任何进一步执行错误的作业。

总结一下

setUnscheduleFiringTrigger =>停止调用此特定作业运行的触发器 setUnscheduleAllTriggers =>停止调用此作业的所有触发器

有关Exception用法的示例,请参见http://quartz-scheduler.org/documentation/quartz-2.x/examples/Example6 。

In quartz you can have multiple triggers firing your job. If the reason for the job execution to fail is inherent in the trigger, you may want to unschedule that specific trigger. That is my understanding of setUnscheduleFiringTrigger(true).

If the problem is with the job itself and not the trigger, it would fail on every execution, no matter who or what started it. So to save yourself the hassle of multiple executions failing, just because different triggers fire the job, you can use setUnscheduleAllTriggers(true) to unschedule all the triggers firing this job, preventing any further executions of the faulty job.

So to summarize

setUnscheduleFiringTrigger => Stop the trigger that called this specific job-run setUnscheduleAllTriggers => Stop all triggers calling this job

See http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/examples/Example6.html for an example of the Exception's usage.

Quartz异常处理(Quartz exception handling)

我有以下石英工作。 我用它做了一些测试。

public void execute(JobExecutionContext context) throws JobExecutionException { try { Object result = callable.call(); } catch (Exception e) { JobExecutionException e2 = new JobExecutionException(e); if (REFIRE_IMMEDIATELY.equals(policy)) { e2.setRefireImmediately(true); } else if (UNSCHEDULE_ALL_TRIGGERS.equals(policy)) { e2.setUnscheduleAllTriggers(true); } else { e2.setUnscheduleFiringTrigger(true); } throw e2; } }

但我无法完全理解setUnscheduleAllTriggers setUnscheduleFiringTrigger 之间的区别 。 不幸的是,没有Javadoc。

有人可以帮助我吗?

谢谢

I have the following quartz job. I made some test with it.

public void execute(JobExecutionContext context) throws JobExecutionException { try { Object result = callable.call(); } catch (Exception e) { JobExecutionException e2 = new JobExecutionException(e); if (REFIRE_IMMEDIATELY.equals(policy)) { e2.setRefireImmediately(true); } else if (UNSCHEDULE_ALL_TRIGGERS.equals(policy)) { e2.setUnscheduleAllTriggers(true); } else { e2.setUnscheduleFiringTrigger(true); } throw e2; } }

But I can't fully understand what is the difference between setUnscheduleAllTriggers and setUnscheduleFiringTrigger. And unfortunately there is no Javadoc.

Does someone can help me ?

Thanks

最满意答案

在石英中,你可以有多个触发器解雇你的工作。 如果作业执行失败的原因是触发器中固有的,您可能希望取消计划该特定触发器。 这是我对setUnscheduleFiringTrigger(true)的理解。

如果问题在于作业本身而不是触发器,那么无论是谁或是什么启动它,它都会在每次执行时失败。 因此,为了避免多次执行失败的麻烦,只是因为不同的触发器触发了作业,您可以使用setUnscheduleAllTriggers(true)来取消调度触发此作业的所有触发器,从而防止任何进一步执行错误的作业。

总结一下

setUnscheduleFiringTrigger =>停止调用此特定作业运行的触发器 setUnscheduleAllTriggers =>停止调用此作业的所有触发器

有关Exception用法的示例,请参见http://quartz-scheduler.org/documentation/quartz-2.x/examples/Example6 。

In quartz you can have multiple triggers firing your job. If the reason for the job execution to fail is inherent in the trigger, you may want to unschedule that specific trigger. That is my understanding of setUnscheduleFiringTrigger(true).

If the problem is with the job itself and not the trigger, it would fail on every execution, no matter who or what started it. So to save yourself the hassle of multiple executions failing, just because different triggers fire the job, you can use setUnscheduleAllTriggers(true) to unschedule all the triggers firing this job, preventing any further executions of the faulty job.

So to summarize

setUnscheduleFiringTrigger => Stop the trigger that called this specific job-run setUnscheduleAllTriggers => Stop all triggers calling this job

See http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/examples/Example6.html for an example of the Exception's usage.