Class AbstractRetryScheduler
java.lang.Object
org.axonframework.commandhandling.gateway.AbstractRetryScheduler
- All Implemented Interfaces:
RetryScheduler
- Direct Known Subclasses:
ExponentialBackOffIntervalRetryScheduler,IntervalRetryScheduler
An abstract base class for
RetrySchedulers. This class provides methods to do the actual rescheduling and
decides if a given Throwable is explicitly transient.- Since:
- 4.2
- Author:
- Bert Laverman
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder class for theRetrySchedulerimplementations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract longcomputeRetryInterval(CommandMessage commandMessage, RuntimeException lastFailure, List<Class<? extends Throwable>[]> failures) Compute the amount of milliseconds delay until the next retry, given the information passed.protected booleanisExplicitlyNonTransient(Throwable failure) Indicates whether the givenfailureis clearly non-transient.protected booleanscheduleRetry(Runnable commandDispatch, long interval) Schedule the provided task to run after the given interval.booleanscheduleRetry(CommandMessage commandMessage, RuntimeException lastFailure, List<Class<? extends Throwable>[]> failures, Runnable dispatchTask) This is the entrypoint of theRetryScheduler.
-
Constructor Details
-
AbstractRetryScheduler
Construct theAbstractRetrySchedulerfrom its builder.- Parameters:
builder- theAbstractRetryScheduler.Builder
-
-
Method Details
-
scheduleRetry
Schedule the provided task to run after the given interval.- Parameters:
commandDispatch- theRunnableto schedule.interval- the number of milliseconds delay.- Returns:
trueif the task was accepted for scheduling,falseotherwise.
-
computeRetryInterval
protected abstract long computeRetryInterval(CommandMessage commandMessage, RuntimeException lastFailure, List<Class<? extends Throwable>[]> failures) Compute the amount of milliseconds delay until the next retry, given the information passed.- Parameters:
commandMessage- the command that was sent (and failed).lastFailure- the last failure that caused this retry scheduler to be called.failures- aListof all failures up to now.- Returns:
- the number of milliseconds to wait until retrying.
-
isExplicitlyNonTransient
Indicates whether the givenfailureis clearly non-transient. That means, whether thefailureexplicitly states that a retry of the same Command would result in the same failure to occur again. In this implementation, givenfailure(and its causes) is tested against configured composablenonTransientFailurePredicate. By default,nonTransientFailurePredicateis configured only withAxonNonTransientExceptionClassesPredicate.- Parameters:
failure- the exception that occurred while processing a command- Returns:
trueif the exception is clearly non-transient and the command should not be retried, orfalsewhen the command has a chance of succeeding if it retried.
-
scheduleRetry
public boolean scheduleRetry(@Nonnull CommandMessage commandMessage, @Nonnull RuntimeException lastFailure, @Nonnull List<Class<? extends Throwable>[]> failures, @Nonnull Runnable dispatchTask) This is the entrypoint of theRetryScheduler. This default implementation checks if the last failure was transient, and if so reschedules a command dispatch.- Specified by:
scheduleRetryin interfaceRetryScheduler- Parameters:
commandMessage- The Command Message being dispatchedlastFailure- The last failure recorded for this commandfailures- A condensed view of all known failures of this command. Each element in the array represents the cause of the element preceding it.dispatchTask- the task that performs the actual dispatching.- Returns:
trueif rescheduling succeeded,falseif otherwise.
-