public abstract static class AbstractRetryScheduler.Builder<B extends AbstractRetryScheduler.Builder> extends Object
RetryScheduler
implementations.
The default for maxRetryCount
is set to a single retry and the nonTransientFailurePredicate
defaults to AxonNonTransientExceptionClassesPredicate
.
The ScheduledExecutorService
is a hard requirement and as such should be provided.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
<E extends Throwable> |
addNonTransientFailurePredicate(Class<E> failureType,
Predicate<? super E> nonTransientFailurePredicate)
Adds additional predicate into the predicate chain for checking non-transiency of a failure.
|
B |
addNonTransientFailurePredicate(Predicate<Throwable> nonTransientFailurePredicate)
Adds additional predicate into the predicate chain for checking non-transiency of a failure.
|
B |
maxRetryCount(int maxRetryCount)
Sets the maximum number of retries allowed for a single command.
|
<E extends Throwable> |
nonTransientFailurePredicate(Class<E> failureType,
Predicate<? super E> nonTransientFailurePredicate)
Resets the
Predicate chain used for checking non-transiency of a failure. |
B |
nonTransientFailurePredicate(Predicate<Throwable> nonTransientFailurePredicate)
Resets the
Predicate chain used for checking non-transiency of a failure. |
B |
retryExecutor(ScheduledExecutorService retryExecutor)
Sets the
ScheduledExecutorService used to schedule a command retry. |
protected void |
validate()
Validate the fields.
|
public B retryExecutor(@Nonnull ScheduledExecutorService retryExecutor)
ScheduledExecutorService
used to schedule a command retry.retryExecutor
- a ScheduledExecutorService
used to schedule a command retrypublic B nonTransientFailurePredicate(@Nonnull Predicate<Throwable> nonTransientFailurePredicate)
Predicate
chain used for checking non-transiency of a failure. Throws away any previously
existing predicate chain and replaces it with the provided predicate.
Provided nonTransientFailurePredicate
checks whether a failure is transient (predicate returns
false
) or not (predicate returns true
). Non-transient failures are never retried.public <E extends Throwable> B nonTransientFailurePredicate(@Nonnull Class<E> failureType, @Nonnull Predicate<? super E> nonTransientFailurePredicate)
Predicate
chain used for checking non-transiency of a failure. Throws away any previously
existing predicate chain and replaces it with the provided predicate.
Provided nonTransientFailurePredicate
checks whether a failure is transient (predicate returns
false
) or not (predicate returns true
). Non-transient failures are never retried.
In essence, this is just a failure typed variant of nonTransientFailurePredicate(Predicate)
method.E
- type of the failure to handlefailureType
- concrete class of the failure to handlenonTransientFailurePredicate
- a Predicate
(accepting a failureType
parameter) used
for testing transiency of provided failurepublic B addNonTransientFailurePredicate(@Nonnull Predicate<Throwable> nonTransientFailurePredicate)
nonTransientFailurePredicate
is set on the beginning of the predicate chain with
the Predicate#or
operator.public <E extends Throwable> B addNonTransientFailurePredicate(@Nonnull Class<E> failureType, @Nonnull Predicate<? super E> nonTransientFailurePredicate)
nonTransientFailurePredicate
is set on the beginning of the predicate chain with
or
operator.
In essence, this is just a failure typed variant of addNonTransientFailurePredicate(Predicate)
method.E
- type of the failure to handlefailureType
- concrete class of the failure to handlenonTransientFailurePredicate
- an additional Predicate
(accepting a failure
parameter) to be added into the predicate chain used for testing
transiency of provided failurepublic B maxRetryCount(int maxRetryCount)
maxRetryCount
- an int
specifying the maximum number of retries allowed for a single commandprotected void validate() throws AxonConfigurationException
AbstractRetryScheduler
's constructor.AxonConfigurationException
- if validation fails.Copyright © 2010–2024. All rights reserved.