Quartz:
The two basic units of the Quartz dispatch pack are job (job) and Trigger (Trigger). A job is an executable task that can be dispatched, and the trigger provides a schedule for the job. Although the two entities are easy to fit together, it is a reason to separate them in the quartz, and it is also beneficial. By separating the work to be performed from its dispatch, Quartz allows the scheduling trigger to be modified without losing the job itself or the context of the job. Also, any single job can have multiple triggers associated with it
Using Spring Integrated Quartz: This system uses spring to integrate quartz. We only need to configure the appropriate trigger and jobs in spring, without having to write any Java code, and spring will automatically start the job when it finds the beans.
Spring configuration: <bean id= "Dumbjob" class= "Org.springframework.scheduling.quartz.JobDetailBean" >
<property name= "group" value= "dumb"/>
<property name= "Jobclass" value= "example. Dumbjob "/>
<property name= "name" value= "Dumbjob"/>
</bean>
<bean id= "Settlementjob" class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >
<property name= "TargetObject" ref= "Settlementbizfacade"/>
<property name= "Targetmethod" value= "Dosettlement"/>
<property name= "Concurrent" value= "false"/>
<property name= "name" value= "settlement"/>
</bean> <bean id= "Settlementtrigger" class= "Org.springframework.scheduling.quartz.CronTriggerBean" >
<property name= "Jobdetail" ref= "Settlementjob"/>
<!--run at 23:55 everyday--
<property name= "cronexpression" value= "0 55 23 * *?" />
</bean>
<bean class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean" >
<property name= "Triggers" >
<list> <ref bean= "Settlementtrigger"/>
</list> </property> <property name= "Quartzproperties" >
<map> <!--1 job thread, change the If more jobs added--
<entry key= "Org.quartz.threadPool.threadCount" value= "1"/>
</map>
</property>
</bean>
First we need to configure a job, there are two ways: one is to create a separate jobclass for the job, and then use Spring's Jobdetailbean to configure the job The other is to use Methodinvokingjobdetailfactorybean to specify a method, do not need a separate jobclass, it needs to set "TargetObject" and "Targetmethod", The target method is called when the job is triggered by trigger. Here the "concurrent" is set to "false", the called method does not run in the new thread, but is executed sequentially. Next we configure a cron trigger named "Settlementtrigger" that defines the settlementjob appropriate to be called. Finally, you need to configure the Schedulerfactorybean, which is responsible for scheduling all the trigger, and can also configure the quartz. Because the current task interval is far away, there is no requirement for frequent execution, so the number of threads in quartz is set to "1"
Using Spring Integrated Quartz