Quartz misfires not working
I have a cronTrigger which should fire once each night, and in case my standalone application was not alive at that time, I want quartz to fire the trigger when starting up (only once by the way, even if a week passed and trigger should have fired 7 times...).
But I am unable to get any kind of misfires to happen.
Using Quartz 1.5.2 and Spring 2.0.
I have a test job that I am firing each minute:
Code:
public class TestJobBean extends QuartzJobBean implements StatefulJob {
private Log log = LogFactory.getLog(getClass());
public TestJobBean() {
log.debug("test job bean created");
}
@Override
protected void executeInternal(JobExecutionContext context)
throws JobExecutionException {
log.debug("job executing");
log.debug("now=" + new Date());
log.debug("scheduled time=" + context.getScheduledFireTime());
log.debug("actual fire time=" + context.getFireTime());
}
}
I am expecting that when my application has been shut down for a couple of minutes, and I start it again, I should see job printing out sheduled time = X, actual fire time = Y where X << Y.
Related Spring configs:
Code:
<bean id="testJobBean" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.foo.someproject.scheduling.jobs.TestJobBean" />
</bean>
<bean id="testTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="testJobBean"/>
<property name="cronExpression" value="0 * * * * ?" />
<property name="misfireInstructionName" value="MISFIRE_INSTRUCTION_FIRE_ONCE_NOW" />
</bean>
<bean id="scheduler"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="testTrigger" />
</list>
</property>
<property name="jobFactory" ref="jobFactory" />
<property name="schedulerContextAsMap">
<map>
<entry key="travelTimeService" value-ref="travelTimeImportService" />
<entry key="travelTimeImportStatusService" value-ref="travelTimeImportStatusService" />
</map>
</property>
<property name="configLocation">
<value>classpath:quartz.properties</value>
</property>
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="autoStartup" value="false" />
<!-- check if this affects misfires -->
<property name="overwriteExistingJobs" value="true" />
</bean>
<bean id="testBean" class="com.foo.someproject.TestBean">
<property name="scheduler" ref="scheduler" />
</bean>
<bean id="jobFactory" class="org.springframework.scheduling.quartz.SpringBeanJobFactory">
</bean>
Code:
quartz.properties
org.quartz.jobStore.misfireThreshold = 10000
(I have tried without quartz.properties also, I am assuming it should use the default misfire threshold = 60s in that case?)
After running and stopping my application the data in quartz tables:
QRTZ_CRON_TRIGGERS: (trigger_name, trigger_group, cron_expression, time_zone_id)
testTrigger DEFAULT 0 * * * * ? Europe/Helsinki
QRTZ_FIRED_TRIGGERS = empty
QRTZ_TRIGGERS (trigger_name, trigger_group, job_name, job_group, is_volatile, description, next_fire_time, prev_fire_time, trigger_state, trigger_type, start_time, end_time, calendar_name, misfire_instr, job_data):
testTrigger DEFAULT testJobBean DEFAULT 0 1201005300000 1201005240000 WAITING CRON 1201005187000 0 1
QRTZ_JOB_DETAILS (job_name, job_group, desctription, job_class_name, is_durable, is_volatile, is_stateful, requests_recovery, job_data):
testJobBean DEFAULT com.foo.fooproject.scheduling.jobs.TestJobBean 0 0 1 0 (BLOB)