如何取消Quartz中的预定作业 [英] How to cancel a scheduled job in Quartz
问题描述
我正在使用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.
感激不尽的任何想法。
推荐答案
取消安排特定的工作触发器
Unscheduling a Particular Trigger of Job
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屋!