Interface RetryContext

All Superinterfaces:
org.springframework.core.AttributeAccessor
All Known Implementing Classes:
RetryContextSupport

public interface RetryContext extends org.springframework.core.AttributeAccessor
Low-level access to ongoing retry operation. Normally not needed by clients, but can be used to alter the course of the retry, e.g. force an early termination.
Author:
Dave Syer, Emanuele Ivaldi, Marcin ZajÄ…czkowski
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Retry context attribute that is non-null (and true) if the context has been closed.
    static final String
    Retry context attribute that is non-null (and true) if the retry was exhausted.
    static final String
    Retry context attribute that represent the maximum number of attempts for policies that provide a maximum number of attempts before failure.
    static final String
    Retry context attribute name for reporting key.
    static final String
    Retry context attribute that is non-null (and true) if the exception is not recoverable.
    static final String
    Retry context attribute that is non-null (and true) if the recovery path was taken.
    static final String
    Retry context attribute name for state key.
  • Method Summary

    Modifier and Type
    Method
    Description
    Accessor for the exception object that caused the current retry.
    Accessor for the parent context if retry blocks are nested.
    int
    Counts the number of retry attempts.
    boolean
    Public accessor for the exhausted flag setExhaustedOnly().
    void
    Signal to the framework that no more attempts should be made to try or retry the current RetryCallback.

    Methods inherited from interface org.springframework.core.AttributeAccessor

    attributeNames, computeAttribute, getAttribute, hasAttribute, removeAttribute, setAttribute
  • Field Details

    • NAME

      static final String NAME
      Retry context attribute name for reporting key. Can be used for reporting purposes, for instance in a retry listener, to accumulate data about the performance of a retry.
      See Also:
    • STATE_KEY

      static final String STATE_KEY
      Retry context attribute name for state key. Can be used to identify a stateful retry from its context.
      See Also:
    • CLOSED

      static final String CLOSED
      Retry context attribute that is non-null (and true) if the context has been closed.
      See Also:
    • RECOVERED

      static final String RECOVERED
      Retry context attribute that is non-null (and true) if the recovery path was taken.
      See Also:
    • EXHAUSTED

      static final String EXHAUSTED
      Retry context attribute that is non-null (and true) if the retry was exhausted.
      See Also:
    • NO_RECOVERY

      static final String NO_RECOVERY
      Retry context attribute that is non-null (and true) if the exception is not recoverable.
      See Also:
    • MAX_ATTEMPTS

      static final String MAX_ATTEMPTS
      Retry context attribute that represent the maximum number of attempts for policies that provide a maximum number of attempts before failure. For other policies the value returned is RetryPolicy.NO_MAXIMUM_ATTEMPTS_SET
      See Also:
  • Method Details

    • setExhaustedOnly

      void setExhaustedOnly()
      Signal to the framework that no more attempts should be made to try or retry the current RetryCallback.
    • isExhaustedOnly

      boolean isExhaustedOnly()
      Public accessor for the exhausted flag setExhaustedOnly().
      Returns:
      true if the flag has been set.
    • getParent

      @Nullable RetryContext getParent()
      Accessor for the parent context if retry blocks are nested.
      Returns:
      the parent or null if there is none.
    • getRetryCount

      int getRetryCount()
      Counts the number of retry attempts. Before the first attempt this counter is zero, and before the first and subsequent attempts it should increment accordingly.
      Returns:
      the number of retries.
    • getLastThrowable

      @Nullable Throwable getLastThrowable()
      Accessor for the exception object that caused the current retry.
      Returns:
      the last exception that caused a retry, or possibly null. It will be null if this is the first attempt and it finishes successfully, but also if the enclosing policy decides not to provide it (e.g. because of concerns about memory usage).