Annotation Interface Periodic


@Documented @Target({TYPE,METHOD}) @Retention(RUNTIME) @Inherited public @interface Periodic
Annotation placed on methods annotated with HandleSchedule or on the payload class of a Schedule. If this annotation is present the same payload will be rescheduled using the configured delay each time after handling.

By default, the periodic schedule will also be automatically started if it isn't running yet.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Returns true if this periodic schedule should be automatically started if it's not already active.
    boolean
    Returns true if the schedule should continue after an error.
    Define a unix-like cron expression.
    long
    Returns the schedule delay in timeUnit() units.
    long
    Returns the schedule delay in timeUnit() units after handling of the last schedule gave rise to an exception.
    long
    Returns the initial schedule delay.
    Returns the id of the periodic schedule.
    Returns the unit for delay() and initialDelay().
    A time zone id for which the cron expression will be resolved.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Special expression that can be used to disable automatic periodic scheduling if passed to cron().
  • Field Details

    • DISABLED

      static final String DISABLED
      Special expression that can be used to disable automatic periodic scheduling if passed to cron(). If the schedule was already running and is disabled later on using this expression, any previously scheduled messages will be ignored.
      See Also:
  • Element Details

    • cron

      String cron
      Define a unix-like cron expression. If a cron value is specified the delay() in milliseconds is ignored.

      The fields read from left to right are interpreted as follows.

      • minute
      • hour
      • day of month
      • month
      • day of week

      For example, "0 * * * MON-FRI" means at the start of every hour on weekdays.

      It is possible to refer to an application property, e.g. by specifying `${someFetchSchedule}` as cron value. To disable the schedule altogether if the property is *not* set, specify `${someFetchSchedule:-}`.

      See Also:
      Default:
      ""
    • timeZone

      String timeZone
      A time zone id for which the cron expression will be resolved. Defaults to UTC.
      Default:
      "UTC"
    • scheduleId

      String scheduleId
      Returns the id of the periodic schedule. Defaults to the fully qualified name of the schedule class.
      Default:
      ""
    • autoStart

      boolean autoStart
      Returns true if this periodic schedule should be automatically started if it's not already active. Defaults to true.
      Default:
      true
    • delay

      long delay
      Returns the schedule delay in timeUnit() units. Only used if cron() is blank, in which case this value should be a positive number.
      Default:
      -1L
    • continueOnError

      boolean continueOnError
      Returns true if the schedule should continue after an error. Defaults to true.
      Default:
      true
    • delayAfterError

      long delayAfterError
      Returns the schedule delay in timeUnit() units after handling of the last schedule gave rise to an exception.

      If this value is smaller than 0 (the default) this setting is ignored and the schedule will continue as if the exception hadn't been triggered. If continueOnError() is false, this setting is ignored as well.

      Default:
      -1L
    • timeUnit

      TimeUnit timeUnit
      Returns the unit for delay() and initialDelay(). Defaults to TimeUnit.MILLISECONDS.
      Default:
      MILLISECONDS
    • initialDelay

      long initialDelay
      Returns the initial schedule delay. Only relevant when autoStart() is true. If initialDelay is negative, the initial schedule will fire after the default delay (configured either via cron() or delay()).
      Default:
      0L