Class RetryStrategy.FixedIntervalRetryStrategy
java.lang.Object
org.sterl.spring.persistent_tasks.api.RetryStrategy.FixedIntervalRetryStrategy
- All Implemented Interfaces:
RetryStrategy
- Enclosing interface:
RetryStrategy
public static class RetryStrategy.FixedIntervalRetryStrategy
extends Object
implements RetryStrategy
A retry strategy that determines the next retry time by adding a fixed
interval to the current time in the specified temporal unit.
This strategy can be used to create retry intervals that remain constant regardless of the number of attempts, providing a uniform delay between retries.
Example:
If interval = 5
, unit = ChronoUnit.SECONDS
, each retry will
be scheduled after 5 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.boolean
shouldRetry
(int executionCount, Exception error) Determines whether a retry should be attempted based on the current execution count and the provided exception.
-
Constructor Details
-
FixedIntervalRetryStrategy
public FixedIntervalRetryStrategy()
-
-
Method Details
-
shouldRetry
Description copied from interface:RetryStrategy
Determines whether a retry should be attempted based on the current execution count and the provided exception. (optional)- Specified by:
shouldRetry
in interfaceRetryStrategy
- Parameters:
executionCount
- The number of attempts already made.error
- The exception that triggered the retry.- Returns:
true
if the current execution count is less than the maximum execution count;false
otherwise.
-
retryAt
Description copied from interface:RetryStrategy
Calculates the time of the next retry attempt based on the current execution count and the provided exception.- Specified by:
retryAt
in interfaceRetryStrategy
- Parameters:
executionCount
- The number of attempts already made.error
- The exception that triggered the retry.- Returns:
OffsetDateTime
of the next execution,null
for no retry.
-