Top Description Methods
org.eclipse.microprofile.faulttolerance

public @Interface Retry

extends Annotation
Annotations
@Inherited
@Documented
@Retention:RUNTIME
@Target:METHOD, TYPE
@InterceptorBinding
Imports
java.lang.annotation.Documented, .ElementType, .Inherited, .Retention, .RetentionPolicy, .Target, java.time.temporal.ChronoUnit, jakarta.enterprise.util.Nonbinding, jakarta.interceptor.InterceptorBinding

The retry annotation to define the number of retries. Any invalid config value causes org.eclipse.microprofile.faulttolerance.exceptions.FaultToleranceDefinitionException.

When a method returns and the retry policy is present, the following rules are applied:

  1. If the method returns normally (doesn't throw), the result is simply returned.
  2. Otherwise, if the thrown object is assignable to any value in the abortOn() parameter, the thrown object is rethrown.
  3. Otherwise, if the thrown object is assignable to any value in the retryOn() parameter, the method call is retried.
  4. Otherwise the thrown object is rethrown.
If a method throws a Throwable which is not an Error or Exception, non-portable behavior results.
Authors
Emily Jiang, John Ament
See Also
maxRetries(), delay(), delayUnit(), maxDuration(), durationUnit(), jitter(), jitterDelayUnit(), retryOn(), abortOn()

Method Summary

Modifier and TypeMethod and Description
public Class<? extends Throwable>[]

Returns:

the exception types on which to abort (not retry)
abortOn
()

The list of exception types that should not trigger a retry.

public long

Returns:

the delay time
delay
()

The delay between retries.

public ChronoUnit

Returns:

the delay unit
delayUnit
()

The unit for delay.

public ChronoUnit

Returns:

the duration unit
durationUnit
()

The duration unit for maxDuration.

public long

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.
jitter
()

Set the jitter to randomly vary retry delays for.

public ChronoUnit

Returns:

the jitter delay unit
jitterDelayUnit
()

The delay unit for jitter.

public long

Returns:

the maximum duration to perform retries for
maxDuration
()

The max duration.

public int

Returns:

the max number of retries. -1 means retry forever. The value must be greater than or equal to -1.
maxRetries
()

The max number of the retries.

public Class<? extends Throwable>[]

Returns:

the exception types on which to retry
retryOn
()

The list of exception types that should trigger a retry.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

abortOnback to summary
public Class<? extends 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 an Error or Exception, non-portable behavior results.

Returns:Class<? extends Throwable>[]

the exception types on which to abort (not retry)

Annotations
@Nonbinding
delayback to summary
public long delay()

The delay between retries. Defaults to 0. The value must be greater than or equal to 0.

Returns:long

the delay time

Annotations
@Nonbinding
delayUnitback to summary
public ChronoUnit delayUnit()

The unit for delay. Defaults to java.time.temporal.ChronoUnit#MILLIS if not set.

Returns:ChronoUnit

the delay unit

Annotations
@Nonbinding
durationUnitback to summary
public ChronoUnit durationUnit()

The duration unit for maxDuration. Defaults to java.time.temporal.ChronoUnit#MILLIS if not set.

Returns:ChronoUnit

the duration unit

Annotations
@Nonbinding
jitterback to summary
public 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:long

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.

Annotations
@Nonbinding
jitterDelayUnitback to summary
public ChronoUnit jitterDelayUnit()

The delay unit for jitter. Defaults to java.time.temporal.ChronoUnit#MILLIS if not set.

Returns:ChronoUnit

the jitter delay unit

Annotations
@Nonbinding
maxDurationback to summary
public long maxDuration()

The max duration. The max duration must be greater than the delay duration if set. 0 means not set.

Returns:long

the maximum duration to perform retries for

Annotations
@Nonbinding
maxRetriesback to summary
public int maxRetries()

The max number of the retries.

Returns:int

the max number of retries. -1 means retry forever. The value must be greater than or equal to -1.

Annotations
@Nonbinding
retryOnback to summary
public Class<? extends Throwable>[] retryOn()

The list of exception types that should trigger a retry.

Note that if a method throws a Throwable which is not an Error or Exception, non-portable behavior results.

Returns:Class<? extends Throwable>[]

the exception types on which to retry

Annotations
@Nonbinding