Package org.springframework.retry
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic 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 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 TypeMethodDescriptionAccessor 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 flagsetExhaustedOnly()
.void
Signal to the framework that no more attempts should be made to try or retry the currentRetryCallback
.Methods inherited from interface org.springframework.core.AttributeAccessor
attributeNames, computeAttribute, getAttribute, hasAttribute, removeAttribute, setAttribute
-
Field Details
-
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
Retry context attribute name for state key. Can be used to identify a stateful retry from its context.- See Also:
-
CLOSED
Retry context attribute that is non-null (and true) if the context has been closed.- See Also:
-
RECOVERED
Retry context attribute that is non-null (and true) if the recovery path was taken.- See Also:
-
EXHAUSTED
Retry context attribute that is non-null (and true) if the retry was exhausted.- See Also:
-
NO_RECOVERY
Retry context attribute that is non-null (and true) if the exception is not recoverable.- See Also:
-
-
Method Details
-
setExhaustedOnly
void setExhaustedOnly()Signal to the framework that no more attempts should be made to try or retry the currentRetryCallback
. -
isExhaustedOnly
boolean isExhaustedOnly()Public accessor for the exhausted flagsetExhaustedOnly()
.- Returns:
- true if the flag has been set.
-
getParent
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
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, but also if the enclosing policy decides not to provide it (e.g. because of concerns about memory usage).
-