http://wzping.iteye.com/blog/468263
1. Define a job
<!--use Pojo to do job, specify Pojo and Method--
<bean id= "Jobdetail" class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >
<property name= "TargetObject" ref= "Pojoobject"/>
<property name= "Targetmethod" value= "Execute"/>
</bean>
2. Define a trigger time
<bean id= "Crontrigger" class= "Org.springframework.scheduling.quartz.CronTriggerBean" >
<property name= "Jobdetail" ref= "Jobdetail"/>
<!--run every half hour for nine to five working hours--
<property name= "cronexpression" value= "0 0/30 9-17 *,* *?" />
</bean>
3. Definition Manager
<bean name= "Quartzscheduler"
class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean" >
<property name= "Triggers" >
<list>
<ref bean= "Crontrigger"/>
</list>
</property>
</bean>
General application, as long as the configuration above these things can be.
But if there are a lot of timing procedures, and sometimes need to start separately, this time to use two scheduler, in spring is how to achieve it? Simply configuring the two Schedulerfactorybean does not solve the problem. The reasons are as follows:
Take a look at the Schedulerfactorybean code, inside a parameter called: Schedulername,schedulerfactorybean returns a specific scheduler by stdschedulerfactory. And each scheduler is registered in the schedulerrepository.
Each scheduler in the schedulerrepository is placed in a map, based on the name as key.
Private HashMap schedulers;
It's better to do it.
<bean name= "Quartzscheduler"
class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean" >
<property name= "Triggers" >
<list>
<ref bean= "Crontrigger"/>
</list>
</property>
<property name= "Schedulername" ><value>first</value></property>
</bean>
You can declare more than one. and set a different name, so that scheduler have multiple instances, can be started separately, stopped.
How to run multiple schedulers quartz instances in spring