Package io.smallrye.faulttolerance.api
Annotation Type RetryWhen
@Inherited
@Documented
@Retention(RUNTIME)
@Target({METHOD,TYPE})
@Experimental("first attempt at providing predicate-based retries")
public @interface RetryWhen
Modifies a
@Retry annotation to retry when given predicate returns true.
May only be present on elements that are also annotated @Retry. If this annotation
is present and the @RetryWhen.exception member is set, the @Retry.retryOn
and @Retry.abortOn members must not be set.
For each usage of the @RetryWhen annotation, all given Predicates are
instantiated once. The predicate classes must have a public, zero-parameter
constructor. They must be thread-safe, ideally stateless.
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass of the predicate that will be used to determine whether the action should be retried if the action has thrown an exception.Class of the predicate that will be used to determine whether the action should be retried if the action has returned a result.
-
Element Details
-
result
Class of the predicate that will be used to determine whether the action should be retried if the action has returned a result.Even if the guarded action is asynchronous, the predicate takes a produced result. The predicate is never passed a
CompletionStageor so.- Returns:
- predicate class
- Default:
io.smallrye.faulttolerance.api.NeverOnResult.class
-
exception
Class of the predicate that will be used to determine whether the action should be retried if the action has thrown an exception.Even if the guarded action is asynchronous, the predicate takes a produced exception. The predicate is never passed a
CompletionStageor so.- Returns:
- predicate class
- Default:
io.smallrye.faulttolerance.api.AlwaysOnException.class
-