Selection of different types of trigger

Source: Internet
Author: User

1.SimpleTrigger is generally used to implement tasks at regular intervals, and how many times, such as executing every 60 seconds and repeating 6 times.

Problem: (1) in the process of using the discovery set execution 6 is actually performed 7 times, one is executed at the beginning of the first 0 seconds, and then perform the given number of executions based on the execution interval.

(2) When there is a misfired task and resumes execution, the execution time is random (depending on when the misfired task is performed, such as a day's 6:00pm). This results in a daily execution time that becomes 6:00pm, not the time we originally expected. (PS: Because of this problem, I consider not to provide external simpletrigger, and swap with Dailytimeintervaltrigger)



2. Crontirgger uses a Task Scheduler command crontab similar to the Linux/unix, see the cron expression for a detailed introduction to Quartz. For schedules that involve weeks and months, Crontirgger is the most suitable, and even in some cases, the only option. For example, "00 06 06?" * WED 2014 "represents 2014 per month for each Wednesday of 06:06am performing tasks.



3. Dailytimeintervaltrigger will be within a given time interval every N (1, 2, 3 ...) Seconds or hours to perform the task. For example: set to run from Monday to Friday 10:10 ~ 18:00 every 60 minutes. Although Simpletrigger can achieve similar tasks, Dailytimeintervaltrigger is not subject to the misfired tasks mentioned above.



4.CalendarIntervalTrigger is typically used to process recurring interval tasks based on calendar time. You can handle tasks that Simpletrigger cannot handle (for example, a different number of seconds per month) and tasks that Crontrigger cannot handle (for example, a divisor that is not 12 per 5 months).



In addition to the 4 types of Trigger,quartz mentioned above, a Calendar class (Org.quartz.Calendar) is defined. The Calendar class is used with Trigger, which is used to exclude tasks from being executed. For example, according to the rules of Trigger, a task is required on May 1, but Holidaycalendar specifies that May 1 is a legal holiday, so the task will not be executed on that day. Of course, the Calendar class does not only provide the exclusion of holidays, but also the cron expression exclusion and other sub-class implementation.

Selection of different types of trigger

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.