Class RetryStrategy.MultiplicativeRetryStrategy
java.lang.Object
org.sterl.spring.persistent_tasks.api.RetryStrategy.MultiplicativeRetryStrategy
- All Implemented Interfaces:
RetryStrategy
- Enclosing interface:
RetryStrategy
public static class RetryStrategy.MultiplicativeRetryStrategy
extends Object
implements RetryStrategy
A retry strategy that determines the next retry time by multiplying
the execution count by a scaling factor and adding the result to the
current time in the specified temporal unit.
This strategy can be used to create retry intervals that increase multiplicatively with the number of attempts, providing a way to progressively delay retries.
Example:
If scalingFactor = 2, unit = ChronoUnit.SECONDS, and
executionCount = 3, the next retry will be scheduled after
2 * 3 = 6 seconds from the current time.
Note: The retry attempts will stop once the maximum execution count
(maxExecutionCount) is reached.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.sterl.spring.persistent_tasks.api.RetryStrategy
RetryStrategy.FixedIntervalRetryStrategy, RetryStrategy.LinearRetryStrategy, RetryStrategy.MultiplicativeRetryStrategy -
Field Summary
Fields inherited from interface org.sterl.spring.persistent_tasks.api.RetryStrategy
NO_RETRY, THREE_RETRIES, THREE_RETRIES_IMMEDIATELY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCalculates the time of the next retry attempt based on the current execution count and the provided exception.booleanshouldRetry(int executionCount, Exception error) Determines whether a retry should be attempted based on the current execution count and the provided exception.
-
Constructor Details
-
MultiplicativeRetryStrategy
public MultiplicativeRetryStrategy()
-
-
Method Details
-
shouldRetry
Description copied from interface:RetryStrategyDetermines whether a retry should be attempted based on the current execution count and the provided exception. (optional)- Specified by:
shouldRetryin interfaceRetryStrategy- Parameters:
executionCount- The number of attempts already made.error- The exception that triggered the retry.- Returns:
trueif the current execution count is less than the maximum execution count;falseotherwise.
-
retryAt
Description copied from interface:RetryStrategyCalculates the time of the next retry attempt based on the current execution count and the provided exception.- Specified by:
retryAtin interfaceRetryStrategy- Parameters:
executionCount- The number of attempts already made.error- The exception that triggered the retry.- Returns:
OffsetDateTimeof the next execution,nullfor no retry.
-