Class RetryPolicySettings
java.lang.Object
org.springframework.boot.retry.RetryPolicySettings
Settings for a
RetryPolicy
.- Since:
- 4.0.0
- Author:
- Stephane Nicoll
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate aRetryPolicy
based on the state of this instance.getDelay()
Return the base delay after the initial invocation.@Nullable Duration
Return the jitter period to enable random retry attempts.Return the maximum number of retry attempts.Return the maximum delay for any retry attempt.Return the value to multiply the current interval by for each attempt.void
Specify the base delay after the initial invocation.void
setFactory
(@Nullable Function<RetryPolicy.Builder, RetryPolicy> factory) Set the factory to use to create theRetryPolicy
, ornull
to use the default.void
Specify a jitter period for the base retry attempt, randomly subtracted or added to the calculated delay, resulting in a value betweendelay - jitter
anddelay + jitter
but never below the base delay or above the max delay.void
setMaxAttempts
(Long maxAttempts) Specify the maximum number of retry attempts.void
setMaxDelay
(Duration maxDelay) Specify the maximum delay for any retry attempt, limiting how far jitter and the multiplier can increase the delay.void
setMultiplier
(Double multiplier) Specify a multiplier for a delay for the next retry attempt.
-
Field Details
-
DEFAULT_MAX_ATTEMPTS
public static final long DEFAULT_MAX_ATTEMPTSDefault number of retry attempts.- See Also:
-
DEFAULT_DELAY
Default initial delay. -
DEFAULT_MULTIPLIER
public static final double DEFAULT_MULTIPLIERDefault multiplier, uses a fixed delay.- See Also:
-
DEFAULT_MAX_DELAY
Default maximum delay (infinite).
-
-
Constructor Details
-
RetryPolicySettings
public RetryPolicySettings()
-
-
Method Details
-
createRetryPolicy
Create aRetryPolicy
based on the state of this instance.- Returns:
- a
RetryPolicy
-
getMaxAttempts
Return the maximum number of retry attempts.- Returns:
- the maximum number of retry attempts
- See Also:
-
setMaxAttempts
Specify the maximum number of retry attempts.- Parameters:
maxAttempts
- the max attempts (must be equal or greater than zero)
-
getDelay
Return the base delay after the initial invocation.- Returns:
- the base delay
- See Also:
-
setDelay
Specify the base delay after the initial invocation.If a multiplier is specified, this serves as the initial delay to multiply from.
- Parameters:
delay
- the base delay (must be greater than or equal to zero)
-
getJitter
Return the jitter period to enable random retry attempts.- Returns:
- the jitter value
-
setJitter
Specify a jitter period for the base retry attempt, randomly subtracted or added to the calculated delay, resulting in a value betweendelay - jitter
anddelay + jitter
but never below the base delay or above the max delay.If a multiplier is specified, it is applied to the jitter value as well.
- Parameters:
jitter
- the jitter value (must be positive)
-
getMultiplier
Return the value to multiply the current interval by for each attempt. The default value,1.0
, effectively results in a fixed delay.- Returns:
- the value to multiply the current interval by for each attempt
- See Also:
-
setMultiplier
Specify a multiplier for a delay for the next retry attempt.- Parameters:
multiplier
- value to multiply the current interval by for each attempt (must be greater than or equal to 1)
-
getMaxDelay
Return the maximum delay for any retry attempt.- Returns:
- the maximum delay
-
setMaxDelay
Specify the maximum delay for any retry attempt, limiting how far jitter and the multiplier can increase the delay.The default is unlimited.
- Parameters:
maxDelay
- the maximum delay (must be positive)- See Also:
-
setFactory
Set the factory to use to create theRetryPolicy
, ornull
to use the default. The function takes aRetryPolicy.Builder
initialized with the state of this instance that can be further configured, or ignored to restart from scratch.- Parameters:
factory
- a factory to customize the retry policy.
-