public interface TimedRetryAlgorithmWithContext extends TimedRetryAlgorithmA timed retry algorithm is responsible for the following operations, based on the previous attempt settings and current time:
- Creating first attempt TimedAttemptSettings.
- Accepting a task for retry so another attempt will be made.
- Canceling retrying process so the related java.util.concurrent.Future will be canceled.
- Creating TimedAttemptSettings for each subsequent retry attempt.
Implementations of this interface receive a RetryingContext that can contain specific RetrySettings and retryable codes that should be used to determine the retry behavior.
Implementations of this interface must be be thread-save.
Implements
TimedRetryAlgorithmMethods
createFirstAttempt(RetryingContext context)
public abstract TimedAttemptSettings createFirstAttempt(RetryingContext context)Creates a first attempt TimedAttemptSettings.
| Parameter | |
|---|---|
| Name | Description |
context |
RetryingContexta RetryingContext that can contain custom RetrySettings and retryable codes |
| Returns | |
|---|---|
| Type | Description |
TimedAttemptSettings |
first attempt settings |
createNextAttempt(RetryingContext context, TimedAttemptSettings previousSettings)
public abstract TimedAttemptSettings createNextAttempt(RetryingContext context, TimedAttemptSettings previousSettings)Creates a next attempt TimedAttemptSettings, which defines properties of the next attempt.
| Parameters | |
|---|---|
| Name | Description |
context |
RetryingContexta RetryingContext that can contain custom RetrySettings and retryable codes |
previousSettings |
TimedAttemptSettingsprevious attempt settings |
| Returns | |
|---|---|
| Type | Description |
TimedAttemptSettings |
next attempt settings or |
shouldRetry(RetryingContext context, TimedAttemptSettings nextAttemptSettings)
public abstract boolean shouldRetry(RetryingContext context, TimedAttemptSettings nextAttemptSettings)Returns true if another attempt should be made, or false otherwise.
| Parameters | |
|---|---|
| Name | Description |
context |
RetryingContexta RetryingContext that can contain custom RetrySettings and retryable codes. |
nextAttemptSettings |
TimedAttemptSettingsattempt settings, which will be used for the next attempt, if accepted |
| Returns | |
|---|---|
| Type | Description |
boolean |
|