如何暂停石英调度程序中的作业?
您好,我正在创建一个应用程序,该应用程序基于 cron 表达式执行类的方法。为此,我正在使用 springquartz,其中我必须在 spring 文件中配置所有这些内容,它工作正常并且作业基于 cron 表达式执行,但现在我想暂停基于 java 类的特定作业的下一次执行关于用户从 UI 中的选择。那么有什么办法可以做到这一点吗?
我可以获得上下文中所有正在运行的作业的详细信息吗?如果是这样,那么我可以过滤作业并尝试暂停该作业以供下次执行。
Hi i am creating an application that executes the method of a class based on a cron expression. For that i am using spring quartz in which i have to configure all these stuffs in my spring-file it works fine and jobs are executing based on the cron expression, But now i want to suspend the next execution of particular job in java class based on the choice of a user from UI. Then is there any way to do this ??
can i get the details of all running job it the context ? if so then i can filter the jobs and try to suspend that job for next execution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
注入您的 SchedulerFactoryBean。使用它的 getScheduler 方法来获取quartz 调度程序并使用rescheduleJob 或来自quartz API 的其他方法来执行您的任务。
Inject your SchedulerFactoryBean. Use it's
getScheduler
method to obtain a quartz Scheduler and use rescheduleJob or other methods from quartz API to perform your task.我通过使用以下代码
stdScheduler 是一个 ScheduleFactoryBean使其工作
I got it work by use of following code
stdScheduler is a scheduleFactoryBean
我们可以使用 stdScheduler.pauseJob(JobKey jobKey) 方法来减少上面代码中提到的循环次数
We can use the stdScheduler.pauseJob(JobKey jobKey) method to reduce the number of loops mentioned in the code above
如果您通过注入或其他方式获得 SchedulerFactoryBean,则有一些方便的方法:
直接使用 Quartz 时,这也有效:
If you got hold of the SchedulerFactoryBean by injection or somehow else there are the convenience methods:
When using Quartz directly also this works: