JavaQuartz作业持久性 [英] JavaQuartz Job persistence

查看:85
本文介绍了JavaQuartz作业持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Java Quartz不太熟悉,我们只是使用了每天安排的测试作业.对于我们的Struts2 Web应用程序,我们希望运行一些安排在一天中不同时间的日常工作.作业应处于持久性状态,以便即使由于服务器关闭/应用程序失败而导致作业失败,也应在服务器启动后稍后重新执行.我还可以将作业的状态/结果存储在DB中,以便监视作业.任何建议都会有所帮助.

I am not much familiar with Java Quartz, we just used a test job thats scheduled daily. For our Struts2 webapplication, we want to run a few daily jobs that are scheduled at different times of the day. The jobs should be in persistence state such that even if the jobs fails due to server down/application failed, they should re-execute later when server is up. Also can i store the status/results of the jobs in DB, so as to monitor the jobs. Any suggestions would be helpful.

-谢谢

推荐答案

在Quartz调度程序中,您所提到的一切都是可能的,并且已经具有触发器的功能,我们通常将其称为 Misfire指令博士说说吧

Whatever you have mentioned is possible in Quartz scheduler and there is already a feature with triggers which we generally call Misfire Instructionsthis is what doc say about it

触发器的另一个重要属性是其失火指令".如果由于调度程序被关闭,或者因为Quartz的线程池中没有可用的线程来执行作业,而持久触发器错过"了其触发时间,则会发生失火.不同的触发器类型具有不同的失火指令.默认情况下,它们使用智能策略"指令-该指令具有基于触发器类型和配置的动态行为.调度程序启动时,它将搜索任何未触发的持久性触发器,然后根据它们各自配置的未触发指令更新它们中的每一个.当您开始在自己的项目中使用Quartz时,应该使自己熟悉在给定触发器类型上定义的失火指令,并在其JavaDoc中进行了说明.有关失火指令的更多具体信息将在针对每种触发器类型的教程课程中提供.

Another important property of a Trigger is its "misfire instruction". A misfire occurs if a persistent trigger "misses" its firing time because of the scheduler being shutdown, or because there are no available threads in Quartz's thread pool for executing the job. The different trigger types have different misfire instructions available to them. By default they use a 'smart policy' instruction - which has dynamic behavior based on trigger type and configuration. When the scheduler starts, it searches for any persistent triggers that have misfired, and it then updates each of them based on their individually configured misfire instructions. When you start using Quartz in your own projects, you should make yourself familiar with the misfire instructions that are defined on the given trigger types, and explained in their JavaDoc. More specific information about misfire instructions will be given within the tutorial lessons specific to each trigger type.

关于作业持久性Quartz带有很少的内置机制,您需要将JobStore设置为 JDBCJobStore

Regarding Job persistence Quartz comes with few build in mechanism and all you need to set JobStore as JDBCJobStore

我建议您使用 Quartz调度程序文件容易,并且有很多教程和示例开始.

I suggest you to go with Quartz scheduler document its quite easy and have lots of tutorial and examples to start with.

如果您不在应用程序中使用Spring,则无需添加额外的抽象级别和依赖关系.

If you are not using Spring in your application there is no need to add extra level of abstraction and dependencies.

这篇关于JavaQuartz作业持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆