Class AbstractRetryScheduler

java.lang.Object
org.axonframework.commandhandling.gateway.AbstractRetryScheduler
All Implemented Interfaces:
RetryScheduler
Direct Known Subclasses:
ExponentialBackOffIntervalRetryScheduler, IntervalRetryScheduler

public abstract class AbstractRetryScheduler extends Object implements RetryScheduler
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
  • Constructor Details

  • Method Details

    • scheduleRetry

      protected boolean scheduleRetry(Runnable commandDispatch, long interval)
      Schedule the provided task to run after the given interval.
      Parameters:
      commandDispatch - the Runnable to schedule.
      interval - the number of milliseconds delay.
      Returns:
      true if the task was accepted for scheduling, false otherwise.
    • 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 - a List of all failures up to now.
      Returns:
      the number of milliseconds to wait until retrying.
    • isExplicitlyNonTransient

      protected boolean isExplicitlyNonTransient(Throwable failure)
      Indicates whether the given failure is clearly non-transient. That means, whether the failure explicitly states that a retry of the same Command would result in the same failure to occur again.

      In this implementation, given failure (and its causes) is tested against configured composable nonTransientFailurePredicate. By default, nonTransientFailurePredicate is configured only with AxonNonTransientExceptionClassesPredicate.

      Parameters:
      failure - the exception that occurred while processing a command
      Returns:
      true if the exception is clearly non-transient and the command should not be retried, or false when 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 the RetryScheduler. This default implementation checks if the last failure was transient, and if so reschedules a command dispatch.
      Specified by:
      scheduleRetry in interface RetryScheduler
      Parameters:
      commandMessage - The Command Message being dispatched
      lastFailure - The last failure recorded for this command
      failures - 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:
      true if rescheduling succeeded, false if otherwise.