• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring and Quartz integration

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to use the Scheduler component of Spring (in particular the Quartz scheduler), I configured the class that extends QuartzJobBean and the CronTriggerBean and also the XML Spring config file but I don't know what to run in order to start the scheduler.
Any help?

Thank you.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's move this to the Application Framework forum, where the Spring-savvy folks hang out.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would need to configure a SchedulerFactoryBean, specifying the list of triggers that would be created by the factory, then create an ApplicationContext. When the ApplicationContext is created, the Quartz scheduler will be created and started.
 
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as only quartz concern,
This three line of code you have to implement

String configFile = getServletContext().getRealPath("\\WEB-INF\\ddc-quartz.properties");//cfg.getInitParameter("config-file");
SchedulerFactory sf = new StdSchedulerFactory(configFile);
scheduler = sf.getScheduler();
JobDetail jobDetail = new JobDetail("QuARTZJOB",Scheduler.DEFAULT_GROUP,QuartZJob.class);
CronTrigger trigger = new CronTrigger("QUARTZJOBTrigger","QUARTZCollectionTriggerGroup");
trigger.setCronExpression(cfg.getInitParameter("cronExpr"));
scheduler.scheduleJob(jobDetail, trigger);



the above code you need to write in the servlet init method. The deploy the servlet when application starts. Mention your trigger in config parameter.

I have not worked with Spring, but I believe Quartz is indepened application. You just need to deploy the quartz servlet and mention triggers.
 
reply
    Bookmark Topic Watch Topic
  • New Topic