Interface TimedRetryAlgorithmWithContext (2.72.1)

publicinterface TimedRetryAlgorithmWithContextextendsTimedRetryAlgorithm

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)

publicabstractTimedAttemptSettingscreateFirstAttempt(RetryingContextcontext)

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)

publicabstractTimedAttemptSettingscreateNextAttempt(RetryingContextcontext,TimedAttemptSettingspreviousSettings)

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)

publicabstractbooleanshouldRetry(RetryingContextcontext,TimedAttemptSettingsnextAttemptSettings)

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

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年11月19日 UTC.