Class RetryPolicy.Builder
- Enclosing interface:
- RetryPolicy
RetryPolicy with common configuration
options.- Since:
- 7.0
- Author:
- Sam Brannen, Mahmoud Ben Hassine
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final longThe default delay: 1000L ms.static final longThe default max attempts: 3L.static final longThe default max delay: 9223372036854775807L ms.static final doubleThe default multiplier: 1.0.
- 
Method SummaryModifier and TypeMethodDescriptionSpecify theBackOffstrategy to use.build()Build the configuredRetryPolicy.Specify the base delay after the initial invocation.final RetryPolicy.BuilderSpecify the types of exceptions for which theRetryPolicyshould not retry a failed operation.excludes(Collection<Class<? extends Throwable>> types) Specify the types of exceptions for which theRetryPolicyshould not retry a failed operation.final RetryPolicy.BuilderSpecify the types of exceptions for which theRetryPolicyshould retry a failed operation.includes(Collection<Class<? extends Throwable>> types) Specify the types of exceptions for which theRetryPolicyshould retry a failed operation.Specify a jitter value for the base retry attempt, randomly subtracted or added to the calculated delay, resulting in a value betweendelay - jitteranddelay + jitterbut never below the base delay or above the max delay.maxAttempts(long maxAttempts) Specify the maximum number of retry attempts.Specify the maximum delay for any retry attempt, limiting how far jitter and the multiplier can increase the delay.multiplier(double multiplier) Specify a customPredicatethat theRetryPolicywill use to determine whether to retry a failed operation based on a givenThrowable.
- 
Field Details- 
DEFAULT_MAX_ATTEMPTS
- 
DEFAULT_DELAY
- 
DEFAULT_MAX_DELAYpublic static final long DEFAULT_MAX_DELAYThe default max delay: 9223372036854775807L ms.- See Also:
 
- 
DEFAULT_MULTIPLIER
 
- 
- 
Method Details- 
backOffSpecify theBackOffstrategy to use.The supplied value will override any previously configured value. WARNING: If you configure a custom BackOffstrategy, you should not configure any of the following:maxAttempts,delay,jitter,multiplier, ormaxDelay.- Parameters:
- backOff- the- BackOffstrategy
- Returns:
- this Builderinstance for chained method invocations
 
- 
maxAttemptsSpecify the maximum number of retry attempts.The default is 3L. The supplied value will override any previously configured value. You should not specify this configuration option if you have configured a custom BackOffstrategy.- Parameters:
- maxAttempts- the maximum number of retry attempts; must be positive (or zero for no retry)
- Returns:
- this Builderinstance for chained method invocations
 
- 
delaySpecify the base delay after the initial invocation.If a multiplier is specified, this serves as the initial delay to multiply from. The default is 1000L milliseconds. The supplied value will override any previously configured value. You should not specify this configuration option if you have configured a custom BackOffstrategy.- Parameters:
- delay- the base delay, typically in milliseconds or seconds; must be greater than or equal to zero
- Returns:
- this Builderinstance for chained method invocations
- See Also:
 
- 
jitterSpecify a jitter value for the base retry attempt, randomly subtracted or added to the calculated delay, resulting in a value betweendelay - jitteranddelay + jitterbut never below the base delay or above the max delay.If a multiplier is specified, it is applied to the jitter value as well. The default is no jitter. The supplied value will override any previously configured value. You should not specify this configuration option if you have configured a custom BackOffstrategy.- Parameters:
- jitter- the jitter value, typically in milliseconds; must be greater than or equal to zero
- Returns:
- this Builderinstance for chained method invocations
- See Also:
 
- 
multiplierSpecify a multiplier for a delay for the next retry attempt, applied to the previous delay (starting with the initial delay) as well as to the applicable jitter for each attempt.The default is 1.0, effectively resulting in a fixed delay. The supplied value will override any previously configured value. You should not specify this configuration option if you have configured a custom BackOffstrategy.- Parameters:
- multiplier- the multiplier value; must be greater than or equal to 1
- Returns:
- this Builderinstance for chained method invocations
- See Also:
 
- 
maxDelaySpecify the maximum delay for any retry attempt, limiting how far jitter and the multiplier can increase the delay.The default is unlimited. The supplied value will override any previously configured value. You should not specify this configuration option if you have configured a custom BackOffstrategy.- Parameters:
- maxDelay- the maximum delay; must be greater than zero
- Returns:
- this Builderinstance for chained method invocations
- See Also:
 
- 
includesSpecify the types of exceptions for which theRetryPolicyshould retry a failed operation.Defaults to all exception types. The supplied exception types will be matched against an exception thrown by a failed operation as well as nested causes. If included exception types have already been configured, the supplied types will be added to the existing list of included types. This can be combined with other includes,excludes, and a custompredicate.- Parameters:
- types- the types of exceptions to include in the policy
- Returns:
- this Builderinstance for chained method invocations
- See Also:
 
- 
includesSpecify the types of exceptions for which theRetryPolicyshould retry a failed operation.Defaults to all exception types. The supplied exception types will be matched against an exception thrown by a failed operation as well as nested causes. If included exception types have already been configured, the supplied types will be added to the existing list of included types. This can be combined with other includes,excludes, and a custompredicate.- Parameters:
- types- the types of exceptions to include in the policy
- Returns:
- this Builderinstance for chained method invocations
- See Also:
 
- 
excludesSpecify the types of exceptions for which theRetryPolicyshould not retry a failed operation.The supplied exception types will be matched against an exception thrown by a failed operation as well as nested causes. If excluded exception types have already been configured, the supplied types will be added to the existing list of excluded types. This can be combined with includes, otherexcludes, and a custompredicate.- Parameters:
- types- the types of exceptions to exclude from the policy
- Returns:
- this Builderinstance for chained method invocations
- See Also:
 
- 
excludesSpecify the types of exceptions for which theRetryPolicyshould not retry a failed operation.The supplied exception types will be matched against an exception thrown by a failed operation as well as nested causes. If excluded exception types have already been configured, the supplied types will be added to the existing list of excluded types. This can be combined with includes, otherexcludes, and a custompredicate.- Parameters:
- types- the types of exceptions to exclude from the policy
- Returns:
- this Builderinstance for chained method invocations
- See Also:
 
- 
predicateSpecify a customPredicatethat theRetryPolicywill use to determine whether to retry a failed operation based on a givenThrowable.If a predicate has already been configured, the supplied predicate will be combined with the existing predicate. This can be combined with includesandexcludes.- Parameters:
- predicate- a custom predicate
- Returns:
- this Builderinstance for chained method invocations
- See Also:
 
- 
buildBuild the configuredRetryPolicy.
 
-