Annotation Interface Backoff


@Target(TYPE) @Retention(RUNTIME) @Documented public @interface Backoff
Collects metadata for a BackOffPolicy. Features:
  • With no explicit settings the default is a fixed delay of 1000ms
  • Only the delay() set: the backoff is a fixed delay with that value
  • When delay() and maxDelay() are set the backoff is uniformly distributed between the two values
  • With delay(), maxDelay() and multiplier() the backoff is exponentially growing up to the maximum value
  • If, in addition, the random() flag is set then the multiplier is chosen for each delay from a uniform distribution in [1, multiplier-1]
Since:
1.1
Author:
Dave Syer, Gary Russell, Aftab Shaikh
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    long
    A canonical backoff period.
    An expression evaluating to the canonical backoff period.
    long
    The maximum wait (in milliseconds) between retries.
    An expression evaluating to the maximum wait (in milliseconds) between retries.
    double
    If greater than 1.0, used as a multiplier for generating the next delay for backoff; any value less than or equal to 1.0 is treated as 1.0, meaning a fixed delay.
    Evaluates to a value used as a multiplier for generating the next delay for backoff; ; any value less than or equal to 1.0 is treated as 1.0, meaning a fixed delay.
    boolean
    In the exponential case (multiplier() > 1.0) set this to true to have the backoff delays randomized with jitter, so that the maximum delay is multiplier times the previous delay and the distribution is uniform between the two values.
    Evaluates to a value.
    long
    Synonym for delay().
  • Element Details

    • value

      @AliasFor("delay") long value
      Synonym for delay(). When delay() is non-zero, value of this element is ignored, otherwise value of this element is taken.
      Returns:
      the delay in milliseconds (default 1000)
      Default:
      1000L
    • delay

      @AliasFor("value") long delay
      A canonical backoff period. Used as an initial value in the exponential case, and as a minimum value in the uniform case. When the value of this element is 0, value of element value() is taken, otherwise value of this element is taken and value() is ignored.
      Returns:
      the initial or canonical backoff period in milliseconds (default 1000)
      Default:
      1000L
    • maxDelay

      long maxDelay
      The maximum wait (in milliseconds) between retries. If less than the delay() then the default of 30000L is applied.
      Returns:
      the maximum delay between retries (default 0 = ignored)
      Default:
      0L
    • multiplier

      double multiplier
      If greater than 1.0, used as a multiplier for generating the next delay for backoff; any value less than or equal to 1.0 is treated as 1.0, meaning a fixed delay.
      Returns:
      a multiplier to use to calculate the next backoff delay (default 0 = ignored)
      Default:
      0.0
    • delayExpression

      String delayExpression
      An expression evaluating to the canonical backoff period. Used as an initial value in the exponential case, and as a minimum value in the uniform case. Overrides delay(). Use #{...} for one-time evaluation during initialization, omit the delimiters for evaluation at runtime.
      Returns:
      the initial or canonical backoff period in milliseconds.
      Since:
      1.2
      Default:
      ""
    • maxDelayExpression

      String maxDelayExpression
      An expression evaluating to the maximum wait (in milliseconds) between retries. If less than the delay() then the default of 30000L is applied. Overrides maxDelay(). Use #{...} for one-time evaluation during initialization, omit the delimiters for evaluation at runtime.
      Returns:
      the maximum delay between retries (default 0 = ignored)
      Since:
      1.2
      Default:
      ""
    • multiplierExpression

      String multiplierExpression
      Evaluates to a value used as a multiplier for generating the next delay for backoff; ; any value less than or equal to 1.0 is treated as 1.0, meaning a fixed delay. Overrides multiplier(). Use #{...} for one-time evaluation during initialization, omit the delimiters for evaluation at runtime.
      Returns:
      a multiplier expression to use to calculate the next backoff delay (default 0 = ignored)
      Since:
      1.2
      Default:
      ""
    • random

      boolean random
      In the exponential case (multiplier() > 1.0) set this to true to have the backoff delays randomized with jitter, so that the maximum delay is multiplier times the previous delay and the distribution is uniform between the two values.
      Returns:
      the flag to signal randomization is required (default false)
      Default:
      false
    • randomExpression

      String randomExpression
      Evaluates to a value. In the exponential case (multiplier() > 1.0) set this to true to have the backoff delays randomized, so that the maximum delay is multiplier times the previous delay and the distribution is uniform between the two values. This expression is always evaluated during initialization. If the expression returns true then ExponentialRandomBackOffPolicy is used else ExponentialBackOffPolicy is used.
      Returns:
      the flag to signal randomization is required (default false)
      Default:
      ""