Annotation Interface Scheduled


@Target({TYPE,PARAMETER,METHOD}) @Retention(RUNTIME) @Documented public @interface Scheduled
Usage: 
 @Scheduled(cron="0 15 10 ? * 6L 2012-2015")// org.quartz cron expression: Fire at 10:15am on every last Friday of every month during the years 2012, 2013, 2014 and 2015
 @Scheduled(dayOfMonth = 1, hour=2, minute=3)// monthly: every 2:03am 1st day of the month
 @Scheduled(daysOfWeek=1, hour=14, minute=15)// weekly: 2:15pm every Sunday
 @Scheduled(daysOfWeek={1, 6, 7}, hour=14, minute=15)// weekly: 2:15pm every Sunday, Friday and Saturday
 @Scheduled(hour = 14, minute = 15, second = 16)// daily: 2:15:16pm everyday
 @Scheduled(minute = 15, second = 16)// hourly: every hour at the 15th minute and the 16th second
 @Scheduled(second = 16)// minutely: every minute at the 16th second
 @Scheduled(fixedRateMs = 10_000, initialDelayMs=5_000)// start job after 5 seconds, run job every 10 secsonds no matter how long the job takes
 @Scheduled(fixedDelayMs = 10_000, initialDelayMs=5_000)// start job after 5 seconds, when the job finished wait 10 seconds then start it again
 
Author:
Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
    The name of a static field defined in the same class, which contains a configurable value
    int[]
    1-31: for monthlyOnDayAndHourAndMinute(int dayOfMonth, int hour, int minute)
    The name of a static field defined in the same class, which contains a configurable value
    int[]
    1-7 for SUN-SAT: for atHourAndMinuteOnGivenDaysOfWeek(int hour, int minute, Integer[] daysOfWeek)
    The name of a static field defined in the same class, which contains a configurable value
    long
    The fixedDelay makes sure that there is a delay of n millisecond between the finish time of an execution of a task and the start time of the next execution of the task.
    The name of a static field defined in the same class, which contains a configurable value
    long
    The fixedRate runs the scheduled task at every n millisecond.
    The name of a static field defined in the same class, which contains a configurable value
    int
    0-23: for dailyAtHourAndMinute(int hour, int minute)
    The name of a static field defined in the same class, which contains a configurable value
    long
    start job after n millisecond
    The name of a static field defined in the same class, which contains a configurable value
    int
    0-59
    The name of a static field defined in the same class, which contains a configurable value
    int
    0-59
    The name of a static field defined in the same class, which contains a configurable value
  • Element Details

    • cron

      String[] cron
      Default:
      {}
    • cronField

      String cronField
      The name of a static field defined in the same class, which contains a configurable value
      Returns:
      Default:
      ""
    • daysOfMonth

      int[] daysOfMonth
      1-31: for monthlyOnDayAndHourAndMinute(int dayOfMonth, int hour, int minute)
      Returns:
      Default:
      {}
    • daysOfMonthField

      String daysOfMonthField
      The name of a static field defined in the same class, which contains a configurable value
      Returns:
      Default:
      ""
    • daysOfWeek

      int[] daysOfWeek
      1-7 for SUN-SAT: for atHourAndMinuteOnGivenDaysOfWeek(int hour, int minute, Integer[] daysOfWeek)
      Returns:
      Default:
      {}
    • daysOfWeekField

      String daysOfWeekField
      The name of a static field defined in the same class, which contains a configurable value
      Returns:
      Default:
      ""
    • hour

      int hour
      0-23: for dailyAtHourAndMinute(int hour, int minute)
      Returns:
      Default:
      -1
    • hourField

      String hourField
      The name of a static field defined in the same class, which contains a configurable value
      Returns:
      Default:
      ""
    • minute

      int minute
      0-59
      Returns:
      Default:
      -1
    • minuteField

      String minuteField
      The name of a static field defined in the same class, which contains a configurable value
      Returns:
      Default:
      ""
    • second

      int second
      0-59
      Returns:
      Default:
      -1
    • secondField

      String secondField
      The name of a static field defined in the same class, which contains a configurable value
      Returns:
      Default:
      ""
    • fixedRateMs

      long fixedRateMs
      The fixedRate runs the scheduled task at every n millisecond. It doesn't check for any previous executions of the task.

      This is useful when all executions of the task are independent. If we don't expect to exceed the size of the memory and the thread pool, fixedRate should be quite handy.

      Although, if the incoming tasks do not finish quickly, it's possible they end up with “Out of Memory exception”.

      Returns:
      Default:
      0L
    • fixedRateMsField

      String fixedRateMsField
      The name of a static field defined in the same class, which contains a configurable value
      Returns:
      Default:
      ""
    • fixedDelayMs

      long fixedDelayMs
      The fixedDelay makes sure that there is a delay of n millisecond between the finish time of an execution of a task and the start time of the next execution of the task.

      This property is specifically useful when you need to make sure that only one instance of the task runs all the time. For dependent jobs, it is quite helpful.

      Returns:
      Default:
      0L
    • fixedDelayMsField

      String fixedDelayMsField
      The name of a static field defined in the same class, which contains a configurable value
      Returns:
      Default:
      ""
    • initialDelayMs

      long initialDelayMs
      start job after n millisecond
      Returns:
      Default:
      0L
    • initialDelayMsField

      String initialDelayMsField
      The name of a static field defined in the same class, which contains a configurable value
      Returns:
      Default:
      ""