我在Spring的Quartz中使用Quartz在每月的第一天午夜運行特定任務。我已經通過在本月的最後一天將服務器日期&的時間設置爲11:59來測試該作業,啓動服務器並觀察任務運行時間爲12:00,但我擔心的情況是服務器(無論出於何種原因)可能不會在本月的第一天的午夜時間運行。運行錯過的Quartz作業
我認爲在Quartz中的失火處理會照顧到這一點,但也許我錯了嗎?
任何人都可以告訴我如何我可以處理這個?我真的不想創建一個每'x'秒/分鐘/小時運行的作業,並檢查是否需要運行該作業,如果我能避免它。
我也很好奇爲什麼我沒有看到任何Quartz相關的日誌記錄信息,但這是次要問題。
下面是任務我的Spring配置:
<bean id="schedulerService" class="com.bah.pams.service.scheduler.SchedulerService">
<property name="surveyResponseDao" ref="surveyResponseDao"/>
<property name="organizationDao" ref="organizationDao"/>
</bean>
<bean name="createSurveyResponsesJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.bah.pams.service.scheduler.jobs.CreateSurveyResponsesJob"/>
<property name="jobDataAsMap">
<map>
<entry key="schedulerService" value-ref="schedulerService"/>
</map>
</property>
</bean>
<!-- Cron Trigger -->
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="createSurveyResponsesJob"/>
<property name="cronExpression" value="0 0 0 1 * ? *"/>
<!--if the server is down at midnight on 1st of month, run this job as soon as it starts up next -->
<property name="misfireInstructionName" value="MISFIRE_INSTRUCTION_FIRE_ONCE_NOW"/>
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="autoStartup" value="true"/>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
<prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
</props>
</property>
<property name="jobDetails">
<list>
<ref bean="createSurveyResponsesJob"/>
</list>
</property>
<property name="triggers">
<list>
<ref bean="cronTrigger"/>
</list>
</property>
</bean>