Class DefaultRetryState
java.lang.Object
org.springframework.retry.support.DefaultRetryState
- All Implemented Interfaces:
RetryState
- Author:
- Dave Syer
-
Constructor Summary
ConstructorDescriptionDefaultRetryState
(Object key) Defaults the force refresh flag (to false) and the rollback classifier (to null).DefaultRetryState
(Object key, boolean forceRefresh) Defaults the rollback classifier to null.DefaultRetryState
(Object key, boolean forceRefresh, Classifier<? super Throwable, Boolean> rollbackClassifier) Create aDefaultRetryState
representing the state for a new retry attempt.DefaultRetryState
(Object key, Classifier<? super Throwable, Boolean> rollbackClassifier) Defaults the force refresh flag to false. -
Method Summary
Modifier and TypeMethodDescriptiongetKey()
Key representing the state for a retry attempt.boolean
Indicate whether a cache lookup can be avoided.boolean
rollbackFor
(Throwable exception) Check whether this exception requires a rollback.toString()
-
Constructor Details
-
DefaultRetryState
public DefaultRetryState(Object key, boolean forceRefresh, Classifier<? super Throwable, Boolean> rollbackClassifier) Create aDefaultRetryState
representing the state for a new retry attempt.- Parameters:
key
- the key for the state to allow this retry attempt to be recognisedforceRefresh
- true if the attempt is known to be a brand new state (could not have previously failed)rollbackClassifier
- the rollback classifier to set. The rollback classifier answers true if the exception provided should cause a rollback.- See Also:
-
DefaultRetryState
Defaults the force refresh flag to false.- Parameters:
key
- the keyrollbackClassifier
- the rollbackClassifier
- See Also:
-
DefaultRetryState
Defaults the rollback classifier to null.- Parameters:
key
- the keyforceRefresh
- whether to force a refresh- See Also:
-
DefaultRetryState
Defaults the force refresh flag (to false) and the rollback classifier (to null).- Parameters:
key
- the key to use- See Also:
-
-
Method Details
-
getKey
Description copied from interface:RetryState
Key representing the state for a retry attempt. Stateful retry is characterised by having to recognise the items that are being processed, so this value is used as a cache key in between failed attempts.- Specified by:
getKey
in interfaceRetryState
- Returns:
- the key that this state represents
-
isForceRefresh
public boolean isForceRefresh()Description copied from interface:RetryState
Indicate whether a cache lookup can be avoided. If the key is known ahead of the retry attempt to be fresh (i.e. has never been seen before) then a cache lookup can be avoided if this flag is true.- Specified by:
isForceRefresh
in interfaceRetryState
- Returns:
- true if the state does not require an explicit check for the key
-
rollbackFor
Description copied from interface:RetryState
Check whether this exception requires a rollback. The default is always true, which is conservative, so this method provides an optimisation for switching to stateless retry if there is an exception for which rollback is unnecessary. Example usage would be for a stateful retry to specify a validation exception as not for rollback.- Specified by:
rollbackFor
in interfaceRetryState
- Parameters:
exception
- the exception that caused a retry attempt to fail- Returns:
- true if this exception should cause a rollback
-
toString
-