简体   繁体   English

如何更改群集石英作业的时间表?

[英]How to change schedule of clustered quartz job?

As far as I tried, I have to manually change the CRON_TRIGGERS table in DB. 据我所试,我必须在数据库中手动更改CRON_TRIGGERS表。 Dirty... 脏...

Any way to make more like this?: 有什么办法可以像这样吗?

  1. There are 2 apps running, both have in .properties file schedule defined as "every minute" and so works the job 有2个应用程序正在运行,两个应用程序在.properties文件中的时间表都定义为“每分钟”,因此可以正常工作
  2. I stop one instance and reconfigure (change in .properties file), so the schedule is "every hour" 我停止了一个实例并重新配置(在.properties文件中更改),因此计划是“每个小时”
  3. I start the instance. 我启动实例。 Now I would like that instace to check, that such job is already defined in DB and to update the schedule there. 现在,我希望该实例进行检查,以确保该作业已在DB中定义并在那里更新时间表。 It is not happening now using configuration from site http://www.objectpartners.com/2013/07/09/configuring-quartz-2-with-spring-in-clustered-mode/ 现在无法使用网站http://www.objectpartners.com/2013/07/09/configuring-quartz-2-with-spring-in-clustered-mode/中的配置来进行

Or what is the typical solution? 或典型的解决方案是什么?

  1. So I guess that when you say .properties file, you actually mean the spring bean XML file(s). 所以我想您说.properties文件时,实际上是指spring bean XML文件。
  2. It does not make any sense that you statically configure identical jobs with different schedules. 您用不同的时间表静态配置相同的作业没有任何意义。 If for whatever reason, one instance restarts, it will automatically apply its own schedule. 如果出于某种原因,一个实例重新启动,它将自动应用自己的日程表。 If statically configured, your job triggers should be the same on all instances 如果是静态配置的,则您的作业触发器在所有实例上都应该相同
  3. If you properly set <property name="overwriteExistingJobs" value="true"/> in your SchedulerFactoryBean it should automatically updates the schedule of the job. 如果在SchedulerFactoryBean正确设置了<property name="overwriteExistingJobs" value="true"/> ,它将自动更新作业计划。
  4. You should never modify the database manually. 您永远不要手动修改数据库。 Always update the scheduler through its API. 始终通过其API更新调度程序。

Try sth like this: 尝试这样:

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="jobDetails">
            <list>
                <ref bean="yourJobDetail" />
            </list>
        </property>
        <property name="triggers">
            <list>
                <ref bean="yourJobTrigger" />
            </list>
        </property>
        <property name="configLocation" value="file:${HOME}/yourProperties.properties" />
        <!-- Commented, because don't work with autocommit = false on spring data source -->
        <!-- <property name="dataSource" ref="mainDataSource"/> -->
        <property name="transactionManager" ref="mainTransactionManager" />
        <property name="autoStartup" value="true" />
        <property name="applicationContextSchedulerContextKey" value="applicationContext" />
        <property name="jobFactory">
            <bean class="FactoryForJobWithInjectionOfSpringBbean" />
        </property>
        <!-- Will update database cron triggers to what is in this jobs file on each deploy. Replaces all previous trigger and job data that 
            was in the database. YMMV -->
        <!-- dont work properly with cluster -->
        <!-- <property name="overwriteExistingJobs" value="true" /> -->
    </bean>

Unfortunately i think that: 不幸的是,我认为:

<property name="overwriteExistingJobs" value="true" />

dosen't work correctly in cluster mode. 在群集模式下无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM