Quartz Integration with Spring -


i have web application , trying start quartz scheduler programmatically in spring. have service class create instance of schedulerfactory , scheduler.

the code follows.

@service("auctionwinnerservice") public class normalauctionwinnerserviceimpl implements auctionwinnerservice {      public static final string normal_auction = "normal auction";     public static int normal_auction_counter = 0;     private schedulerfactory schedulerfactory;     private scheduler scheduler;      public void declarewinner(int auctionid, map<string, object> parametermap) {         system.out.println("inside declarewinner of normalauctionwinner");         schedulerfactory = new stdschedulerfactory();         try {             scheduler = schedulerfactory.getscheduler();             system.out.println("got scheduler : "+scheduler);         } catch (schedulerexception e1) {             e1.printstacktrace();         }          jobdetail jd = new jobdetail();         jd.setname(normal_auction+" job "+normal_auction_counter);         jd.setjobclass(normalauctionwinnerjob.class);          /** create cron trigger instance **/         crontrigger t = new crontrigger();         t.setname(normal_auction + ++normal_auction_counter);         t.setgroup("normal auction");         date d = new date();         date d1 = new date();         d1.setminutes(d.getminutes()+5);          t.setstarttime(d);         t.setendtime(d1);         try {             t.setcronexpression("10 * * * * ? *");             scheduler.schedulejob(jd, t);         } catch (schedulerexception e) {             e.printstacktrace();         } catch (parseexception e) {             e.printstacktrace();         }     } } 

the schedulerfactory , scheduler instantiated jobs not run. point out missing here?

also need 1 instance of factory , 1 scheduler instance. tried making static didn't work. pointers in direction helpful.

thanks

unless have specific requirement on quartz's proprietary functionality, recommend getting rid of , using spring's internal scheduling capability. of spring 3, includes support cron-type expressions, similar quartz's cron trigger.

as bringing simplicity application , config, it's inherently more reliable quartz, , provides easier api programmatic usage, via taskscheduler interface.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -