Interface RetryStrategy
- All Known Subinterfaces:
AdaptiveRetryStrategy,DefaultAwareRetryStrategy,LegacyRetryStrategy,StandardRetryStrategy
- All Known Implementing Classes:
BaseRetryStrategy,DefaultAdaptiveRetryStrategy,DefaultLegacyRetryStrategy,DefaultStandardRetryStrategy,RetryPolicyAdapter
We do not recommend SDK users create their own retry strategies. We recommend refining an existing strategy:
- If you are using the strategy with a service, you can get the existing strategy
from that service via
[ServiceName]Client.defaults().retryStrategy(). RetryStrategiesfrom thesoftware.amazon.awssdk:retriesmodule.
Terminology:
- An attempt is a single invocation of an action.
- The attempt count is which attempt (starting with 1) the SDK is attempting to make.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRetryStrategy.Builder<B extends RetryStrategy.Builder<B,T>, T extends RetryStrategy> Builder to create immutable instances ofRetryStrategy. -
Method Summary
Modifier and TypeMethodDescriptionInvoked before the first request attempt.intReturns the maximum numbers attempts that this retry policy will allow.recordSuccess(RecordSuccessRequest request) Invoked after an attempt succeeds.Invoked before each subsequent (non-first) request attempt.Create a newRetryStrategy.Builderwith the current configuration.default booleanReturns whether the retry strategy uses default retry predicates.
-
Method Details
-
acquireInitialToken
Invoked before the first request attempt.Callers MUST wait for the
delayreturned by this call before making the first attempt. Callers that wish to retry a failed attempt MUST callrefreshRetryToken(software.amazon.awssdk.retries.api.RefreshRetryTokenRequest)before doing so.If the attempt was successful, callers MUST call
recordSuccess(software.amazon.awssdk.retries.api.RecordSuccessRequest).- Throws:
NullPointerException- if a required parameter is not specifiedTokenAcquisitionFailedException- if a token cannot be acquired
-
refreshRetryToken
Invoked before each subsequent (non-first) request attempt.Callers MUST wait for the
delayreturned by this call before making the next attempt. If the next attempt fails, callers MUST re-callrefreshRetryToken(software.amazon.awssdk.retries.api.RefreshRetryTokenRequest)before attempting another retry. This call invalidates the provided token, and returns a new one. Callers MUST use the new token.If the attempt was successful, callers MUST call
recordSuccess(software.amazon.awssdk.retries.api.RecordSuccessRequest).- Throws:
NullPointerException- if a required parameter is not specifiedIllegalArgumentException- if the provided token was not issued by this strategy or the provided token was already used for a previous refresh or success call.TokenAcquisitionFailedException- if a token cannot be acquired
-
recordSuccess
Invoked after an attempt succeeds.- Throws:
NullPointerException- if a required parameter is not specifiedIllegalArgumentException- if the provided token was not issued by this strategy or the provided token was already used for a previous refresh or success call.
-
maxAttempts
int maxAttempts()Returns the maximum numbers attempts that this retry policy will allow.- Returns:
- the maximum numbers attempts that this retry policy will allow.
-
useClientDefaults
default boolean useClientDefaults()Returns whether the retry strategy uses default retry predicates.- Returns:
- true if this retry strategy should use the default retry predicates, false otherwise.
-
toBuilder
RetryStrategy.Builder<?,?> toBuilder()Create a newRetryStrategy.Builderwith the current configuration.This is useful for modifying the strategy's behavior, like conditions or max retries.
-