Interface RetryPolicy

All Superinterfaces:
Serializable
All Known Implementing Classes:
AlwaysRetryPolicy, BinaryExceptionClassifierRetryPolicy, CircuitBreakerRetryPolicy, CompositeRetryPolicy, ExceptionClassifierRetryPolicy, ExpressionRetryPolicy, MaxAttemptsRetryPolicy, NeverRetryPolicy, SimpleRetryPolicy, TimeoutRetryPolicy

public interface RetryPolicy extends Serializable
A RetryPolicy is responsible for allocating and managing resources needed by RetryOperations. The RetryPolicy allows retry operations to be aware of their context. Context can be internal to the retry framework, e.g. to support nested retries. Context can also be external, and the RetryPolicy provides a uniform API for a range of different platforms for the external context.
Author:
Dave Syer
  • Method Details

    • canRetry

      boolean canRetry(RetryContext context)
      Parameters:
      context - the current retry status
      Returns:
      true if the operation can proceed
    • open

      RetryContext open(RetryContext parent)
      Acquire resources needed for the retry operation. The callback is passed in so that marker interfaces can be used and a manager can collaborate with the callback to set up some state in the status token.
      Parameters:
      parent - the parent context if we are in a nested retry.
      Returns:
      a RetryContext object specific to this policy.
    • close

      void close(RetryContext context)
      Parameters:
      context - a retry status created by the open(RetryContext) method of this policy.
    • registerThrowable

      void registerThrowable(RetryContext context, Throwable throwable)
      Called once per retry attempt, after the callback fails.
      Parameters:
      context - the current status object.
      throwable - the exception to throw