Quartz Scheduler仅在尚未运行时执行作业 [英] Quartz Scheduler execute job only if it is not already running

查看:142
本文介绍了Quartz Scheduler仅在尚未运行时执行作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Java Web应用程序中,我正在使用Quartz CronTrigger Bean计划作业的执行。在我的配置xml文件中,我想每10分钟触发一次作业:

In my java web application I am using Quartz CronTrigger Bean to schedule the execution of a job. In my configuration xml file I want to trigger the job every 10 minutes:

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="processToExecuteJob" />
    <property name="cronExpression" value="0 0/10 * * * ?" />
</bean>

如何检查作业是否已经运行,在达不到的情况下,我不需要运行再来一次。
我想确保在某个特定时间只能运行该作业的一个实例。

How can I check if the job is already running, and in tat case I do not need to run it again. I want to ensure that only one instance of the job can be running at certain time.

推荐答案

我从事的一个旧项目中存在类似问题。我认为在这种情况下,一种优雅的解决方案始终是Singleton模式

I had a similar problem in an old project I worked on. I think an elegant solution in this case always the Singleton pattern

http://en.wikipedia.org/wiki/Singleton_pattern

这篇关于Quartz Scheduler仅在尚未运行时执行作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆