-
Quartz and JavaConfig
Hi All,
I have a Quartz SchedulerFactoryBean configured in my JavaConfig, when I have it defined as :
Code:
@Bean(scope = DefaultScopes.SINGLETON, destroyMethodName="destroy")
public SchedulerFactoryBean quartzScheduler() throws ParseException {
SchedulerFactoryBean quartzScheduler = new SchedulerFactoryBean();
Trigger[] triggers = {EmailTrigger(), EscalationTrigger()};
quartzScheduler.setTriggers(triggers);
quartzScheduler.setApplicationContextSchedulerContextKey("applicationContext");
Properties quartzProperties = new Properties();
quartzProperties.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
quartzProperties.put("org.quartz.threadPool.threadCount", "5");
quartzScheduler.setQuartzProperties(quartzProperties);
return quartzScheduler;
}
The Quartz threads do not start up.
If I define it this way:
Code:
@Bean(scope = DefaultScopes.SINGLETON, destroyMethodName="destroy")
public Object quartzScheduler() throws ParseException {
SchedulerFactoryBean quartzScheduler = new SchedulerFactoryBean();
Trigger[] triggers = {EmailTrigger(), EscalationTrigger()};
quartzScheduler.setTriggers(triggers);
quartzScheduler.setApplicationContextSchedulerContextKey("applicationContext");
Properties quartzProperties = new Properties();
quartzProperties.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
quartzProperties.put("org.quartz.threadPool.threadCount", "5");
quartzScheduler.setQuartzProperties(quartzProperties);
return this.getObject(quartzScheduler);
}
The quartz threads start but they do not shutdown when you stop Tomcat. I have tried with and without the destroyMethodName property.
Any help would be greatly appreciated.
Thanks,
Mike
-
Are you ensuring that the close() method is called on the ApplicationContext? Destruction callbacks will not be called unless close() is called on the ApplicationContext.
-
Hi Chris,
I found the probelm it was calling the wrong method.
Thanks for pointing me in the right direction.
-Mike