Annotation Type ExponentialBackoff
-
@Inherited @Documented @Retention(RUNTIME) @Target({METHOD,TYPE}) @Experimental("first attempt at providing additional retry backoff strategies") public @interface ExponentialBackoff
Modifies a@Retryannotation to use exponential backoff instead of the default constant backoff. May only be present on elements that are also annotated@Retry.Exponential backoff uses the initial delay before the first retry attempt, and then increases the delays exponentially. With the default factor of 2, the first few delays are: initial delay, 2 * initial delay, 4 * initial delay, 8 * initial delay, 16 * initial delay, 32 * initial delay, etc. (Additionally, jitter will be applied to each value.) To prevent unbounded growth of these delays,
maxDelay()should be configured.All configuration options of
@Retrystill apply and all their constraints are still enforced. Additionally:delay,delayUnit: is used as an initial delay, before the first retry attempt. Must be less thanmaxDelay(). Note that if 0, exponential backoff degenerates to zero backoff.
- See Also:
factor(),maxDelay(),maxDelayUnit()
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description intfactorThe multiplicative factor used when determining a delay between two retries.longmaxDelayThe maximum delay between retries.ChronoUnitmaxDelayUnitThe unit formaxDelay().
-
-
-
Element Detail
-
factor
int factor
The multiplicative factor used when determining a delay between two retries. A delay is computed asfactor * previousDelay, resulting in an exponential growth.The value must be greater than or equal to 1 (though with factor of 1, exponential backoff degenerates to constant backoff).
- Returns:
- the growth factor
- Default:
- 2
-
-
-
maxDelay
long maxDelay
The maximum delay between retries. Defaults to 1 minute. The value must be greater than or equal to 0, and must be less thanRetry.maxDuration(if that is set). 0 means not set.Note that this is different from
maxDuration. This places a limit on each individual delay between retries, whilemaxDurationplaces a limit on the total time all retries may take.- Returns:
- the max delay time
- Default:
- 60000L
-
-
-
maxDelayUnit
ChronoUnit maxDelayUnit
The unit formaxDelay(). Defaults toChronoUnit.MILLIS.- Returns:
- the max delay unit
- Default:
- java.time.temporal.ChronoUnit.MILLIS
-
-