Class ResilienceConfiguration.RetryConfiguration
java.lang.Object
com.sap.cloud.sdk.cloudplatform.resilience.ResilienceConfiguration.RetryConfiguration
- Enclosing class:
- ResilienceConfiguration
Provides options specific to retries, which will reattempt failed requests a limited amount of times.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default number for maximum attempts.The default predicate for retrying if any exception occurs.static final Duration
The default waiting duration time. -
Method Summary
Modifier and TypeMethodDescriptiondisabled()
Instantiate a newRetryConfiguration
that only permits a single attempt, effectively disabling retries.boolean
int
hashCode()
boolean
Get the status indicator for the Retry.int
The maximum number of total attempts.of
(int maxAttempts) Instantiate a newRetryConfiguration
with the given parameter.Instantiate a newRetryConfiguration
with the given parameters.A predicate which evaluates if an exception should be retried.retryOnExceptionPredicate
(Predicate<Throwable> retryOnExceptionPredicate) A predicate which evaluates if an exception should be retried.The duration to wait before retrying.waitDuration
(Duration waitDuration) The duration to wait before retrying.
-
Field Details
-
DEFAULT_MAX_ATTEMPTS
public static final int DEFAULT_MAX_ATTEMPTSThe default number for maximum attempts.- See Also:
-
DEFAULT_WAIT_DURATION
The default waiting duration time. -
DEFAULT_RETRY_ON_EXCEPTION_PREDICATE
The default predicate for retrying if any exception occurs.
-
-
Method Details
-
isEnabled
public boolean isEnabled()Get the status indicator for the Retry.- Returns:
- True if the configuration is enabled.
-
of
@Nonnull public static ResilienceConfiguration.RetryConfiguration of(int maxAttempts, @Nonnull Duration waitDuration) Instantiate a newRetryConfiguration
with the given parameters.- Parameters:
maxAttempts
- The maximum number of attempts to successfully execute a request.waitDuration
- The time duration the system will wait before retrying.- Returns:
- An immutable
RetryConfiguration
.
-
of
Instantiate a newRetryConfiguration
with the given parameter. Before retrying the system will wait for DEFAULT_WAIT_DURATION.- Parameters:
maxAttempts
- The maximum number of attempts to successfully execute a request.- Returns:
- An instance of
RetryConfiguration
.
-
disabled
Instantiate a newRetryConfiguration
that only permits a single attempt, effectively disabling retries.- Returns:
- A disabled instance of
RetryConfiguration
.
-
equals
-
hashCode
public int hashCode() -
maxAttempts
public int maxAttempts()The maximum number of total attempts. Set this to 1 to not retry failed attempts. -
waitDuration
The duration to wait before retrying. -
retryOnExceptionPredicate
A predicate which evaluates if an exception should be retried. The predicate must return true, if the exception should be retried, otherwise it must return false. By default, all exceptions are retried. -
waitDuration
@Nonnull public ResilienceConfiguration.RetryConfiguration waitDuration(@Nonnull Duration waitDuration) The duration to wait before retrying.- Returns:
this
.
-
retryOnExceptionPredicate
@Nonnull public ResilienceConfiguration.RetryConfiguration retryOnExceptionPredicate(@Nonnull Predicate<Throwable> retryOnExceptionPredicate) A predicate which evaluates if an exception should be retried. The predicate must return true, if the exception should be retried, otherwise it must return false. By default, all exceptions are retried.- Returns:
this
.
-