Java 为什么Quartz作业停止触发,并且触发器的状态从等待变为错误?
问题描述:Java 为什么Quartz作业停止触发,并且触发器的状态从等待变为错误?,java,spring,triggers,quartz-scheduler,jobs,Java,Spring,Triggers,Quartz Scheduler,Jobs,问题描述: <bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false"> <property name="schedulerName" value="IPASScheduler"/> <property name="autoStartup"
<bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false">
<property name="schedulerName" value="IPASScheduler"/>
<property name="autoStartup" value="true" />
<property name="applicationContextSchedulerContextKey" value="applicationContext" />
<property name="waitForJobsToCompleteOnShutdown" value="true" />
<property name="overwriteExistingJobs" value="true" />
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="jobFactory" ref="jobFactoryBean"/>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.misfireThreshold">6000000</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</prop>
<prop key="org.quartz.jobStore.isClustered">true</prop>
<prop key="org.quartz.jobStore.clusterCheckinInterval">20000</prop>
<prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
<prop key="org.quartz.scheduler.instanceName">IPASClusteredScheduler</prop>
<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
<prop key="org.quartz.scheduler.jmx.export">true</prop>
<prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM QRTZ_LOCKS WHERE LOCK_NAME = ?</prop>
<prop key="org.quartz.threadPool.threadCount">10</prop>
<prop key="org.quartz.threadPool.threadPriority">5</prop>
<!-- <prop key="org.quartz.jobStore.dontSetAutoCommitFalse">true</prop> -->
<!-- <prop key="org.quartz.scheduler.wrapJobExecutionInUserTransaction">false</prop> -->
<!-- <prop key="org.quartz.jobStore.useProperties">false</prop> -->
</props>
</property>
</bean>
public class ReportRunnerJob implements Job
{
@Autowired
private SessionFactory sessionFactoryReporting;
@Autowired
private JdbcTemplate jdbcTemplateReporting;
@Autowired
private MailService mailService;*/
@Context
private HttpServletRequest request;
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("Schedular job started");
}
}
我有一个Java服务,它动态创建quartz作业、触发器,并将这些细节保存到与quartz相关的表中
如果我强制停止tomcat服务器,那么“Qrtz_触发器”的触发器状态字段将更改为ERROR。
它永远不会执行
如果我将状态更改为等待,那么它将开始正确执行
石英配置:
<bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false">
<property name="schedulerName" value="IPASScheduler"/>
<property name="autoStartup" value="true" />
<property name="applicationContextSchedulerContextKey" value="applicationContext" />
<property name="waitForJobsToCompleteOnShutdown" value="true" />
<property name="overwriteExistingJobs" value="true" />
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="jobFactory" ref="jobFactoryBean"/>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.misfireThreshold">6000000</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</prop>
<prop key="org.quartz.jobStore.isClustered">true</prop>
<prop key="org.quartz.jobStore.clusterCheckinInterval">20000</prop>
<prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
<prop key="org.quartz.scheduler.instanceName">IPASClusteredScheduler</prop>
<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
<prop key="org.quartz.scheduler.jmx.export">true</prop>
<prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM QRTZ_LOCKS WHERE LOCK_NAME = ?</prop>
<prop key="org.quartz.threadPool.threadCount">10</prop>
<prop key="org.quartz.threadPool.threadPriority">5</prop>
<!-- <prop key="org.quartz.jobStore.dontSetAutoCommitFalse">true</prop> -->
<!-- <prop key="org.quartz.scheduler.wrapJobExecutionInUserTransaction">false</prop> -->
<!-- <prop key="org.quartz.jobStore.useProperties">false</prop> -->
</props>
</property>
</bean>
public class ReportRunnerJob implements Job
{
@Autowired
private SessionFactory sessionFactoryReporting;
@Autowired
private JdbcTemplate jdbcTemplateReporting;
@Autowired
private MailService mailService;*/
@Context
private HttpServletRequest request;
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("Schedular job started");
}
}
作业:
<bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false">
<property name="schedulerName" value="IPASScheduler"/>
<property name="autoStartup" value="true" />
<property name="applicationContextSchedulerContextKey" value="applicationContext" />
<property name="waitForJobsToCompleteOnShutdown" value="true" />
<property name="overwriteExistingJobs" value="true" />
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="jobFactory" ref="jobFactoryBean"/>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.misfireThreshold">6000000</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</prop>
<prop key="org.quartz.jobStore.isClustered">true</prop>
<prop key="org.quartz.jobStore.clusterCheckinInterval">20000</prop>
<prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
<prop key="org.quartz.scheduler.instanceName">IPASClusteredScheduler</prop>
<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
<prop key="org.quartz.scheduler.jmx.export">true</prop>
<prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM QRTZ_LOCKS WHERE LOCK_NAME = ?</prop>
<prop key="org.quartz.threadPool.threadCount">10</prop>
<prop key="org.quartz.threadPool.threadPriority">5</prop>
<!-- <prop key="org.quartz.jobStore.dontSetAutoCommitFalse">true</prop> -->
<!-- <prop key="org.quartz.scheduler.wrapJobExecutionInUserTransaction">false</prop> -->
<!-- <prop key="org.quartz.jobStore.useProperties">false</prop> -->
</props>
</property>
</bean>
public class ReportRunnerJob implements Job
{
@Autowired
private SessionFactory sessionFactoryReporting;
@Autowired
private JdbcTemplate jdbcTemplateReporting;
@Autowired
private MailService mailService;*/
@Context
private HttpServletRequest request;
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("Schedular job started");
}
}
我建议您为quartz启用
DEBUG
日志级别
我猜,当你强行阻止tomcat的时候。
石英触发器尝试加载
ReportRunnerJob
类,在这些停止时刻,它失败并将触发器状态更新为“错误”,日志中有什么?控制台不会显示任何错误日志。。。