Interface TimedRetryAlgorithmWithContext (2.59.0)

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
Name Description
context RetryingContext

a 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 RetryingContext

a RetryingContext that can contain custom RetrySettings and retryable codes

previousSettings TimedAttemptSettings

previous attempt settings

Returns
Type Description
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
Name Description
context RetryingContext

a RetryingContext that can contain custom RetrySettings and retryable codes.

nextAttemptSettings TimedAttemptSettings

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

Returns
Type Description
boolean