Interface TimedRetryAlgorithmWithContext (2.7.1)

public interface TimedRetryAlgorithmWithContext extends TimedRetryAlgorithm

A timed retry algorithm is responsible for the following operations, based on the previous attempt settings and current time:

  1. Creating first attempt TimedAttemptSettings.
  2. Accepting a task for retry so another attempt will be made.
  3. Canceling retrying process so the related java.util.concurrent.Future will be canceled.
  4. 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

TimedRetryAlgorithm

Methods

createFirstAttempt(RetryingContext context)

public abstract TimedAttemptSettings createFirstAttempt(RetryingContext context)

Creates a first attempt TimedAttemptSettings.

Parameter
NameDescription
contextRetryingContext

a RetryingContext that can contain custom RetrySettings and retryable codes

Returns
TypeDescription
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
NameDescription
contextRetryingContext

a RetryingContext that can contain custom RetrySettings and retryable codes

previousSettingsTimedAttemptSettings

previous attempt settings

Returns
TypeDescription
TimedAttemptSettings

next attempt settings or null if the implementing algorithm does not provide specific settings for the next attempt

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
NameDescription
contextRetryingContext

a RetryingContext that can contain custom RetrySettings and retryable codes.

nextAttemptSettingsTimedAttemptSettings

attempt settings, which will be used for the next attempt, if accepted

Returns
TypeDescription
boolean