Spring timed Task (ii) Multiple tasks and execution time interval configuration

Source: Internet
Author: User

Take the previous article (simple example of the basic operation of the spring timed task):

Ii. Spring timed tasks: Multiple tasks and execution interval configuration

1, the use of multiple tasks:

The first step: Write the class and method of performing timed task (multiple, refer to previous article)

Step Two: Configure the configuration file: (refer to previous article)

<bean name= "Quartzscheduler" class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean" >           
        <!--must, Quartzscheduler delay start, after application start Quartzscheduler restart--> <property name= "Startupdelay" value= ""/> <!--common triggers: Triggers list, (you can configure multiple tasks)--> <property name= "triggers" > <list 		
                > <ref local= "Testtrigger"/> <ref local= "TestTrigger1"/> <ref local= "TestTrigger2"/> </list> </property> </bean> <!--Configure classes and methods to perform timed tasks 0--> <bean id= "Testdetail" class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" > <property name= "targetobject" > <bean class= "com.test.Test" ></bean> </property> & Lt;property name= "Targetmethod" > <value>test</value> </property> </bean> <!--configuration Touch Transmitter 0--> <bean id= "testTrigger "class=" Org.springframework.scheduling.quartz.CronTriggerBean "> <property name=" Jobdetail "> <r  
			EF bean= "Testdetail"/> <!--trigger-triggered bean--> </property> <property name= "Cronexpression" > <!--daily 23 o'clock--> <!--scheduled tasks performed at intervals--> <value>0 0 * *?</value> </property> < /bean> <!--Configure classes and methods to perform timed tasks 1--> <bean id= "TestDetail1" class= Ling.quartz.MethodInvokingJobDetailFactoryBean "> <property name=" targetobject "> <b    
            Ean class= "Com.test.Test1" ></bean> </property> <property name= "Targetmethod" > <value>test1</value> </property> </bean> <!--configuration triggers 1--&G     
    T <bean id= "TestTrigger1" class= "Org.springframework.scheduling.quartz.CronTriggerBean" > <p Roperty name="Jobdetail" > <ref bean= "testDetail1"/> <!--a trigger-triggered bean that performs a timed task--> </proper    
            ty> <property name= "Cronexpression" > <!--daily 23 o'clock--> <!--scheduled tasks performed at intervals--> <value>0 0 * *?</value> </property> </bean> <!--configuration execution Class and method of the Task 2--> <bean id= "TestDetail2" class= "Org.springframework.scheduling.quartz.MethodInvokingJ" Obdetailfactorybean "> <property name=" targetobject "> <bean class=" Com.test.Test2 "& gt;</bean> </property> <property name= "Targetmethod" > <value&gt ;test2</value> </property> </bean> <!--configuration triggers 2--> <bean id= "Te StTrigger2 "class=" Org.springframework.scheduling.quartz.CronTriggerBean "> <property name=" J    
      Obdetail ">      <ref bean= "TestDetail2"/> <!--triggers the bean--> </property> <pro of the execution timed task Perty name= "Cronexpression" > <!--daily 23 o'clock--> <!--scheduled tasks performed at intervals--> <value& Gt;0  0 * * *?</value> </property> </bean>
2, the implementation of task time interval settings:

Special characters allowed by field allowed values

Seconds 0-59,-*/

Cent 0-59,-*/

Hour 0-23,-*/

Date 1-31,-*? /LW C

Month 1-12 or JAN-DEC,-*/

Week 1-7 or Sun-sat,-*? /L C #

Year (optional) leave blank, 1970-2099,-*/

Meaning of expression

"0 0 12 * *" Every day 12 o'clock noon.

"0 15 10?" * * "Every 10:15 trigger

"0 15 10 * *" Every day 10:15 trigger

"0 15 10 * * * *" every day 10:15 trigger

"0 15 10 * * *" 2005 "2005 Years ' daily 10:15 trigger

"0 * 14 * *" is triggered every 1 minutes from 2 o'clock in the afternoon to 2:59 every day

"0 0/5 14 * *" is triggered every 5 minutes from 2 o'clock in the afternoon to 2:55 every day

"0 0/5 14,18 * *" triggered every 5 minutes from 2 o'clock in the afternoon to 2:55 and 6 o'clock in the afternoon to 6:55 every day

"0 0-5 14 * *" is triggered every 1 minutes from 2 o'clock in the afternoon to 2:05 every day

"0 10,44 14?" 3WED "Wednesday 2:10 and 2:44 triggers per year of March

"0 15 10?" *mon-fri "Monday to Friday 10:15 trigger

"0 15 10 15 *" Every month 15th 10:15 trigger

"0 L *?" triggered 10:15 the last day of every month

"0 15 10?" *6l "The last Friday 10:15 trigger of the month

"0 15 10?" * 6l2002-2005 "2002 to 2005 the last of the monthly Friday 10:15 trigger

"0 15 10?" *6#3 "The third Friday 10:15 trigger per month

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.