Annotation Type Retry
-
@Inherited @Documented @Retention(RUNTIME) @Target({METHOD,TYPE}) @InterceptorBinding public @interface Retry
The Retry annotation to define the number of the retries. Any invalid config value causesFaultToleranceDefinitionException
.When a method returns and the retry policy is present, the following rules are applied:
- If the method returns normally (doesn't throw), the result is simply returned.
- Otherwise, if the thrown object is assignable to any value in the
abortOn()
parameter, the thrown object is rethrown. - Otherwise, if the thrown object is assignable to any value in the
retryOn()
parameter, the method call is retried. - Otherwise the thrown object is rethrown.
Throwable
which is not anError
orException
, non-portable behavior results.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<? extends java.lang.Throwable>[]
abortOn
The list of exception types that should not trigger a retry.long
delay
The delay between retries.java.time.temporal.ChronoUnit
delayUnit
The unit fordelay()
.java.time.temporal.ChronoUnit
durationUnit
The duration unit formaxDuration()
.long
jitter
Set the jitter to randomly vary retry delays for.java.time.temporal.ChronoUnit
jitterDelayUnit
The delay unit forjitter()
.long
maxDuration
The max duration.int
maxRetries
The max number of the retries.java.lang.Class<? extends java.lang.Throwable>[]
retryOn
The list of exception types that should trigger a retry.
-
-
-
-
delayUnit
java.time.temporal.ChronoUnit delayUnit
The unit fordelay()
. Defaults toChronoUnit.MILLIS
if not set.- Returns:
- the delay unit
- Default:
- java.time.temporal.ChronoUnit.MILLIS
-
-
-
durationUnit
java.time.temporal.ChronoUnit durationUnit
The duration unit formaxDuration()
. Defaults toChronoUnit.MILLIS
if not set.- Returns:
- the duration unit
- Default:
- java.time.temporal.ChronoUnit.MILLIS
-
-
-
jitter
long jitter
Set the jitter to randomly vary retry delays for. The value must be greater than or equals to 0. 0 means not set.
The effective delay will be [delay - jitter, delay + jitter] and always greater than or equal to 0. Negative effective delays will be 0.- Returns:
- the jitter that randomly vary retry delays by. e.g. a jitter of 200 milliseconds will randomly add between -200 and 200 milliseconds to each retry delay.
- Default:
- 200L
-
-
-
jitterDelayUnit
java.time.temporal.ChronoUnit jitterDelayUnit
The delay unit forjitter()
. Defaults toChronoUnit.MILLIS
if not set.- Returns:
- the jitter delay unit.
- Default:
- java.time.temporal.ChronoUnit.MILLIS
-
-
-
retryOn
java.lang.Class<? extends java.lang.Throwable>[] retryOn
The list of exception types that should trigger a retry.Note that if a method throws a
Throwable
which is not anError
orException
, non-portable behavior results.- Returns:
- the exception types on which to retry
- Default:
- {java.lang.Exception.class}
-
-
-
abortOn
java.lang.Class<? extends java.lang.Throwable>[] abortOn
The list of exception types that should not trigger a retry.This list takes priority over the types listed in
retryOn()
.Note that if a method throws a
Throwable
which is not anError
orException
, non-portable behavior results.- Returns:
- the exception types on which to abort (not retry)
- Default:
- {}
-
-