Package org.springframework.retry.policy
Class PredicateRetryPolicy
java.lang.Object
org.springframework.retry.policy.PredicateRetryPolicy
- All Implemented Interfaces:
Serializable
,RetryPolicy
A policy, that is based on
Predicate<Throwable>
. Usually, binary classification
is enough for retry purposes. If you need more flexible classification, use
ExceptionClassifierRetryPolicy
.- Since:
- 2.0.7
- Author:
- Morulai Planinski
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.retry.RetryPolicy
NO_MAXIMUM_ATTEMPTS_SET
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canRetry
(RetryContext context) void
close
(RetryContext status) open
(RetryContext parent) Acquire resources needed for the retry operation.void
registerThrowable
(RetryContext context, Throwable throwable) Called once per retry attempt, after the callback fails.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.retry.RetryPolicy
getMaxAttempts
-
Constructor Details
-
PredicateRetryPolicy
-
-
Method Details
-
canRetry
- Specified by:
canRetry
in interfaceRetryPolicy
- Parameters:
context
- the current retry status- Returns:
- true if the operation can proceed
-
close
- Specified by:
close
in interfaceRetryPolicy
- Parameters:
status
- a retry status created by theRetryPolicy.open(RetryContext)
method of this policy.
-
registerThrowable
Description copied from interface:RetryPolicy
Called once per retry attempt, after the callback fails.- Specified by:
registerThrowable
in interfaceRetryPolicy
- Parameters:
context
- the current status object.throwable
- the exception to throw
-
open
Description copied from interface:RetryPolicy
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.- Specified by:
open
in interfaceRetryPolicy
- Parameters:
parent
- the parent context if we are in a nested retry.- Returns:
- a
RetryContext
object specific to this policy.
-