如何在 Spring 中取消预定的 Quartz 作业
我使用 Spring 将 Quartz 调度程序(使用 Spring 的 TaskScheduler 接口抽象)注入到我的应用程序中,该程序在启动时加载从数据库配置的作业。
它将每个作业添加到调度程序中,如下所示:
TaskScheduler taskScheduler = ...;//injected
Runnable runableThing = ...;
String cronExpression = ...; //from DB
taskScheduler.schedule(runableThing, new CronTrigger(cronExpression));
我的问题是:是否可以指定类似 job_id 之类的内容,随后可用于取消作业/触发器 - 例如响应用户选择要取消的作业网络界面?
我查看了 Spring 文档,但没有找到实现此目的的方法。
任何想法都感激不尽。
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));
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?
I've looked at the Spring docs and can't see a way to do this.
Any ideas gratefully received.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
取消调度作业的特定触发器
删除作业并取消调度其所有触发器
参考:http:// www.opensymphony.com/quartz/wikidocs/UnscheduleJob.html
Unscheduling a Particular Trigger of Job
Deleting a Job and Unscheduling All of Its Triggers
Ref: http://www.opensymphony.com/quartz/wikidocs/UnscheduleJob.html