手动触发 Quartz 作业
我们的应用程序中配置了几个 Quartz 作业。在开发过程中,我们将石英调度程序置于待机状态 - 然而,我们有时希望手动启动作业(出于开发目的)。如果我调用 fireTrigger,它会告诉我需要启动调度程序。但是,如果我启动调度程序,它也会立即调度所有其他作业,这不是我想要的(因为它们可能在我调试手动触发的作业时触发)。
当我启动调度程序时,我可以暂停所有触发器,但随后我必须处理失火指令等。
有没有一种简单的方法可以手动启动作业,而不必处理暂停和失火(即 fireTrigger,即使调度程序处于待机状态)?
We have several Quartz jobs configured in our application. During development, we leave the quartz scheduler in standby - however, we sometimes want to start a job manually (for development purposes). If I call fireTrigger, it tells me I need to start the scheduler. However, if I start the scheduler, it will also immediately schedule all the other jobs, which is not what I want (since they may trigger while I'm debugging the manually fired job).
I could pause all triggers when I start the scheduler, but then I have to deal with misfire instructions etc.
Is there a simple way to fire off a job manually without having to deal with pausing and misfires (i.e. a fireTrigger which works even if the scheduler is in standby)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是手动触发作业所需的循环:
this is the loop you will require to fire the job manually:
所有在 Quartz Scheduler 中注册的 Job 都由 JobKey 唯一标识,JobKey 由名称和组组成。您可以通过调用 Scheduler 实例的
triggerJob(JobKey jobKey)
立即触发具有给定 JobKey 的作业。注意:
All the Jobs registered in the Quartz Scheduler are uniquely identified by the JobKey which is composed of a name and group . You can fire the job which has a given JobKey immediately by calling
triggerJob(JobKey jobKey)
of your Scheduler instance.Note:
你可以尝试在你的调度程序中添加一个触发过滤器,
调试执行过滤器会在执行不是易失性的(不安排立即运行)并且你处于调试模式时添加否决权。
这是一个实现示例:
You can try to add a trigger filter in your scheduler
The debug execution filter will add a veto when the execution is not volatile (not scheduled to run immediately) and you are in debug mode .
Here is an implementation example :
不需要
开始时间
和结束时间
。No need for
start-time
andend-time
.