Results 1 to 3 of 3

Thread: Quartz and JavaConfig

  1. #1
    Join Date
    Nov 2007
    Posts
    18

    Default 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

  2. #2
    Join Date
    Apr 2007
    Posts
    307

    Default

    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.
    Chris Beams
    Spring Framework committer, VMware
    http://github.com/cbeams

  3. #3
    Join Date
    Nov 2007
    Posts
    18

    Default

    Hi Chris,

    I found the probelm it was calling the wrong method.

    Thanks for pointing me in the right direction.

    -Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •