spring 关闭时quartz还没结束

7月 29, 2015 |

遇到如下异常
java.lang.IllegalStateException: JobStore is shutdown - aborting retry
at org.quartz.impl.jdbcjobstore.JobStoreSupport.retryExecuteInNonManagedTXLock(JobStoreSupport.java:3756)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.triggeredJobComplete(JobStoreSupport.java:3039)
at org.quartz.core.QuartzScheduler.notifyJobStoreJobComplete(QuartzScheduler.java:1804)
at org.quartz.core.JobRunShell.run(JobRunShell.java:269)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

这个是由于在spring applicationContext.xml文件中声明SchedulerFactoryBean时没有指定waitForJobsToCompleteOnShutdown属性引起的,将该属性设置为true,这样当spring关闭时,会等待所有已经启动的quartz job结束后spring才能完全shutdown。

Posted in: Quartz

Comments are closed.