Quartz 计划作业未触发 - 可能存在未处理的异常?
我有一个使用 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
这里要注意的重要一点是异常本身没有被捕获。
假设被调用的方法抛出了一个未处理的异常。
public void methodBeingInvoked() throws UnhandledException {
这里会发生什么?
I have a web application with scheduled jobs using the Quartz library. Recently I encountered cases where a job didn't seem like it was being fired. I did some reading and apparently if the job throws an exception, the Quartz scheduler will attempt to execute the job again. Is this true?
In any case, I did some troubleshooting based on the assumption that the above statement is true. So let's say I have the following code snippet:
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
The important point here to note is that Exception itself is not being caught.
So let's say the method being invoked throws an exception which is not handled.
public void methodBeingInvoked() throws UnhandledException {
What happens here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
任何从 Job 抛出的 Throwable 都会被 Quartz 捕获并包装在 JobExecutionException 中,并且不会重新触发。
请参阅 JobRunShell#run
有一些Quartz 网站上的文档与此相矛盾,但在查看 Quartz 1.8 之后.x/2.0.x/2.1.x源代码,所有版本的文档都是错误的。
Any Throwable thrown from a Job will be caught by Quartz and wrapped in a JobExecutionException, and not refired.
See the source code for JobRunShell#run
There is some documentation on the Quartz website which contradicts this, but after looking at Quartz 1.8.x/2.0.x/2.1.x source code, the documentation is wrong for all versions.