我有一个使用Quartz库的预定作业的Web应用程序 . 最近我遇到的情况是工作似乎没有被解雇 . 我做了一些阅读,显然如果作业抛出异常,Quartz调度程序将尝试再次执行作业 . 这是真的?
无论如何,我根据上述陈述是正确的假设做了一些故障排除 . 所以我想说我有以下代码片段:
try {
method.invoke(object, params);
}
catch (ExceptionA ea) {
ea.printStackTrace();
}
catch (ExceptionB eb) {
eb.printStackTrace();
}
// and so on so forth, catching a bunch of specific Exceptions
需要注意的重点是 Exception itself is not being caught .
因此,假设被调用的方法抛出一个未处理的异常 .
public void methodBeingInvoked() throws UnhandledException {
这里发生了什么?
1 回答
从Job中抛出的任何Throwable都将被Quartz捕获并包含在JobExecutionException中,并且不会被激活 . 查看JobRunShell#run的源代码
有一些documentation on the Quartz website与此相矛盾,但在查看Quartz 1.8.x / 2.0.x / 2.1.x源代码之后,所有版本的文档都是错误的 .