如何在春季取消计划的Quartz作业 [英] How to cancel a scheduled Quartz job in Spring
问题描述
我正在使用Spring将Quartz调度程序(由Spring的TaskScheduler接口抽象)注入到我的应用程序中,该程序在启动时加载从数据库配置的作业.
I'm using Spring to inject a Quartz scheduler (abstracted with Spring's TaskScheduler interface) into my app that loads jobs configured from a database at startup.
它在调度程序中添加每个作业,如下所示:
It adds each job in the scheduler something like this:
TaskScheduler taskScheduler = ...;//injected
Runnable runableThing = ...;
String cronExpression = ...; //from DB
taskScheduler.schedule(runableThing, new CronTrigger(cronExpression));
我的问题是:是否可以指定诸如job_id之类的内容,随后可用于取消该作业/触发-例如响应用户在Web界面中选择要取消的作业?
my question is this: Is it possible to specify something like a job_id that can subsequently be used to cancel the job/trigger - say in response to a user selecting the job to be cancelled in the web interface?
我看过Spring文档,但看不到做到这一点的方法.
I've looked at the Spring docs and can't see a way to do this.
感谢收到任何想法.
推荐答案
计划特定的工作触发器
scheduler.unscheduleJob(triggerName, triggerGroup);
删除作业并取消安排所有触发器的时间
Deleting a Job and Unscheduling All of Its Triggers
scheduler.deleteJob(jobName, jobGroup);
参考: http://www.opensymphony.com/quartz/wikidocs/UnscheduleJob. html
这篇关于如何在春季取消计划的Quartz作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!