我正在使用以下Spring配置创建Quartz作业:
<bean class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="name" value="The job"/>
<property name="group" value="The group"/>
<property name="jobClass" value="com.example.myapp.MorningJob"/>
<property name="jobDataMap">
<util:map>
<entry key="key1"
value="val1"/>
<entry key="key2"
value="val2"/>
</util:map>
</property>
</bean>
</property>
<property name="cronExpression" value="0 0 6 * * ? *"/>
<property name="misfireInstruction"
value="#{T(org.quartz.CronTrigger).MISFIRE_INSTRUCTION_FIRE_ONCE_NOW}"/>
<property name="timeZone" ref="timezone"/>
</bean>我的工作看起来像这样
@Configurable
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class MorningJob implements Job { ... }然而,不正确的指令集没有任何影响。经过长时间的应用程序停机后,当触发器多次漏掉时,Quartz尝试多次开始这项工作。
当我试图从context.getTrigger().getMisfireInstruction()中检查MorningJob.execute()时,它会给出0,而CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW是1。
知道为什么没有设置失火指令吗?
发布于 2014-07-23 21:08:38
问题实际上是在我的调度程序配置中。在org.springframework.scheduling.quartz.SchedulerFactoryBean的声明中,我有一个财产
<property name="overwriteExistingJobs" value="false"/>最初,出于测试目的,我将触发器配置为每隔几秒钟运行一次,以查看它是否正常运行。overwriteExistingJobs意味着保存在数据库中的触发器在cron表达式更改后实际上没有更新,misfireInstruction也没有实际应用。要更新触发器,我需要运行scheduler.clear()一次,或者暂时将上述属性设置为true。
我相信在文档中应该更清楚地提到这一点,因为在每次更改之后不更新触发器配置可能真的会令人沮丧。false是overwriteExistingJobs的默认值。
https://stackoverflow.com/questions/24912165
复制相似问题