org.axonframework.commandhandling.gateway
Class IntervalRetryScheduler

java.lang.Object
  extended by org.axonframework.commandhandling.gateway.IntervalRetryScheduler
All Implemented Interfaces:
RetryScheduler

public class IntervalRetryScheduler
extends Object
implements RetryScheduler

RetryScheduler implementation that retries commands at regular intervals when they fail because of an exception that is not explicitly non-transient. Checked exceptions are considered non-transient and will not result in a retry.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
IntervalRetryScheduler(ScheduledExecutorService executor, int interval, int maxRetryCount)
          Initializes the retry scheduler to schedule retries on the given executor using the given interval and allowing maxRetryCount retries before giving up permanently.
 
Method Summary
protected  boolean isExplicitlyNonTransient(Throwable failure)
          Indicates whether the given failure is clearly non-transient.
 boolean scheduleRetry(CommandMessage commandMessage, RuntimeException lastFailure, List<Class<? extends Throwable>[]> failures, Runnable dispatchTask)
          Inspect the given commandMessage that failed with given lastFailure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntervalRetryScheduler

public IntervalRetryScheduler(ScheduledExecutorService executor,
                              int interval,
                              int maxRetryCount)
Initializes the retry scheduler to schedule retries on the given executor using the given interval and allowing maxRetryCount retries before giving up permanently.

Parameters:
executor - The executor on which to schedule retry execution
interval - The interval in milliseconds at which to schedule a retry
maxRetryCount - The maximum number of retries allowed for a single command
Method Detail

scheduleRetry

public boolean scheduleRetry(CommandMessage commandMessage,
                             RuntimeException lastFailure,
                             List<Class<? extends Throwable>[]> failures,
                             Runnable dispatchTask)
Description copied from interface: RetryScheduler
Inspect the given commandMessage that failed with given lastFailure. The given failures provides a list of previous failures known for this command. The commandDispatch task can be used to schedule the command for dispatching.

The return value of this method indicates whether the command has been scheduled for a retry. When true, the original callbacks should not be invoked, as command execution is subject to a retry. When false, the failure is interpreted as terminal and the callback will be invoked with the last failure recorded.

If the implementation throws an Exception, that exception is passed as the failure to the original callback.

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 to be executed to retry a command
Returns:
true if the command has been rescheduled, otherwise false

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.

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.


Copyright © 2010-2016. All Rights Reserved.