Testing for Java triggers

Source: Internet
Author: User

/***************************************spring Configuration Code ***************************************/
<!--trigger Builder class, which generates the trigger object for the specified rule with the scheduler specified--
<bean id= "testtrigger" class= "org.springframework.scheduling.quartz.CronTriggerBean" >
<!--the action to be done after the trigger, this operation is managed by spring, only needs to specify a methodinvokingjobdetailfactorybean--
<property name= "jobdetail" ref= "testjobdetail"/>
<!--trigger rule, where the trigger rule is triggered once every 2 seconds-
<property name= "cronexpression" value= "*/2 * * * *?"/><!---->
</bean>
<!--task builder, which is managed by spring, only needs to specify its corresponding objects and methods, and the execution of the task is an object that calls a method--
<bean id= "testjobdetail"
class= "org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >
<!--specifies the calling object for this task, which class does not need to implement any interfaces--
<property name= "targetObject" ref= "testjob"/>
<!--specify one of the methods in the TargetObject object--
<property name= "targetmethod" value= "execute"/>
<!--whether the task is allowed to execute concurrently. When the value is false, it means that you must wait until the previous thread has finished processing before starting a new thread--
<property name= "concurrent" value= "false"/>
</bean>
<!--a Common class for testing--
<bean id= "testjob" class= "com.wisdom.test.SMSTest.TestJob"/>


/**************************************** the code for the entity class ***************************************/

Package com.wisdom.test.SMSTest;
Import java.util.Date;
public class Testjob {
private static int count = 0;
public void Execute () {
try {
Thread.Sleep (3000);
System.out.println (new Date () + "--task i" + ++count + "times triggered");
} catch (Exception Ex) {
Ex.printstacktrace ();
}
}
}

/******************************* Time Rule *************************************************/
Execute once every 5 seconds: */5 * * * *?
Executes every 1 minutes: 0 */1 * * *?
Executed at 23 o ' day: 0 0 23 * *?
Once daily 1 o'clock in the morning: 0 0 1 * *?
Every month, 1th, 1 o'clock in the morning, once: 0 0 1 1 *?
The last day of the month is executed at 23 points: 0 0 L *?
Once a week, Sunday 1 o'clock in the morning: 0 0 1? * L
At 26, 29, 33, Execute once: 0 26,29,33 * * *?
Every day 0, 13, 18, 21 points are executed once: 0 0 0,13,18,21 * *?

Testing for Java triggers

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.