Quartz 触发器状态不会在服务器启动时持续存在 [英] Quartz trigger state is not persisting on server start

查看:54
本文介绍了Quartz 触发器状态不会在服务器启动时持续存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们要求在应用程序维护之前暂停作业.我们在集群中使用 Quartz 2.2.1.数据库是oracle.

We have a requirement to pause a job before application maintenance. We are using Quartz 2.2.1 in cluster. Database is oracle.

我开发了一个具有暂停"功能的屏幕.我观察到暂停"工作正常,直到我再次启动服务器.在我启动服务器的那一刻,QRTZ_TRIGGERS 表的 TRIGGER_STATE 重置为WAITING".

I have developed a screen with "Pause" functionality. I observed that "pause" works fine until I start the server again. The moment I start server, TRIGGER_STATE of QRTZ_TRIGGERS table resets to "WAITING".

任何人都可以提供提示.

Can anyone please provide a hint.

非常感谢.

Rgds - 罗伊

推荐答案

如果你设置了 overwriteExistingJobs=true (注意默认值为 false) 那么每次服务器启动时,它会从配置文件中加载作业/触发器并替换现有的(具有相同的作业/触发器名称),因此也像您的情况一样覆盖触发器及其状态.

If you have set overwriteExistingJobs=true (note that default value is false) then each time server starts, it loads the jobs/triggers from the configuration file and replaces existing ones (that have the same job/trigger names), therefore overwriting triggers and their states too as in your case.

您可以尝试在 SchedulerFactoryBean 中设置 overwriteExistingJobs=false.然而,这对您来说可能不方便,因为如果您更改服务器中的作业配置,具有旧配置的现有作业将保留在数据库中.

You could try to set overwriteExistingJobs=false in the SchedulerFactoryBean. This however may not be convenient for you, since if you ever change job configuration in the server, the existing jobs with old configuration will remain in the database.

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    ....
    <property name="overwriteExistingJobs" value="false"/>
    <property name="triggers">
        <list>
            ....
        </list>
    </property>
    ....
</bean>

这篇关于Quartz 触发器状态不会在服务器启动时持续存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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