public class IntervalRetryScheduler extends Object implements RetryScheduler
Modifier and Type | Class and Description |
---|---|
static class |
IntervalRetryScheduler.Builder
Builder class to instantiate a
IntervalRetryScheduler . |
Modifier | Constructor and Description |
---|---|
protected |
IntervalRetryScheduler(IntervalRetryScheduler.Builder builder)
Instantiate a
IntervalRetryScheduler based on the fields contained in the IntervalRetryScheduler.Builder . |
Modifier and Type | Method and Description |
---|---|
static IntervalRetryScheduler.Builder |
builder()
Instantiate a Builder to be able to create a
IntervalRetryScheduler . |
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 . |
protected IntervalRetryScheduler(IntervalRetryScheduler.Builder builder)
IntervalRetryScheduler
based on the fields contained in the IntervalRetryScheduler.Builder
.
Will assert that the retryInterval
and maxRetryCount
are positive numbers, and that the
ScheduledExecutorService
is not null
. If any of these does not hold, an
AxonConfigurationException
will be thrown.
builder
- the IntervalRetryScheduler.Builder
used to instantiate a IntervalRetryScheduler
instancepublic static IntervalRetryScheduler.Builder builder()
IntervalRetryScheduler
.
The default for retryInterval
is set to 100ms, while maxRetryCount
gets a single retry.
The retryInterval
, maxRetryCount
and ScheduledExecutorService
are
hard requirements and as such should be provided.
IntervalRetryScheduler
public boolean scheduleRetry(CommandMessage commandMessage, RuntimeException lastFailure, List<Class<? extends Throwable>[]> failures, Runnable dispatchTask)
RetryScheduler
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.scheduleRetry
in interface RetryScheduler
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 to be executed to retry a commandtrue
if the command has been rescheduled, otherwise false
protected boolean isExplicitlyNonTransient(Throwable failure)
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.failure
- the exception that occurred while processing a commandtrue
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–2019. All rights reserved.