Class AbstractRetryScheduler.Builder<B extends AbstractRetryScheduler.Builder>
java.lang.Object
org.axonframework.commandhandling.gateway.AbstractRetryScheduler.Builder<B>
- Direct Known Subclasses:
ExponentialBackOffIntervalRetryScheduler.Builder,IntervalRetryScheduler.Builder
- Enclosing class:
AbstractRetryScheduler
public abstract static class AbstractRetryScheduler.Builder<B extends AbstractRetryScheduler.Builder>
extends Object
A builder class for the
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddNonTransientFailurePredicate(Class<E> failureType, Predicate<? super E> nonTransientFailurePredicate) Adds additional predicate into the predicate chain for checking non-transiency of a failure.addNonTransientFailurePredicate(Predicate<Throwable> nonTransientFailurePredicate) Adds additional predicate into the predicate chain for checking non-transiency of a failure.maxRetryCount(int maxRetryCount) Sets the maximum number of retries allowed for a single command.nonTransientFailurePredicate(Class<E> failureType, Predicate<? super E> nonTransientFailurePredicate) Resets thePredicatechain used for checking non-transiency of a failure.nonTransientFailurePredicate(Predicate<Throwable> nonTransientFailurePredicate) Resets thePredicatechain used for checking non-transiency of a failure.retryExecutor(ScheduledExecutorService retryExecutor) Sets theScheduledExecutorServiceused to schedule a command retry.protected voidvalidate()Validate the fields.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
retryExecutor
Sets theScheduledExecutorServiceused to schedule a command retry.- Parameters:
retryExecutor- aScheduledExecutorServiceused to schedule a command retry- Returns:
- the current Builder instance, for fluent interfacing
-
nonTransientFailurePredicate
Resets thePredicatechain used for checking non-transiency of a failure. Throws away any previously existing predicate chain and replaces it with the provided predicate. ProvidednonTransientFailurePredicatechecks whether a failure is transient (predicate returnsfalse) or not (predicate returnstrue). Non-transient failures are never retried. -
nonTransientFailurePredicate
public <E extends Throwable> B nonTransientFailurePredicate(@Nonnull Class<E> failureType, @Nonnull Predicate<? super E> nonTransientFailurePredicate) Resets thePredicatechain used for checking non-transiency of a failure. Throws away any previously existing predicate chain and replaces it with the provided predicate. ProvidednonTransientFailurePredicatechecks whether a failure is transient (predicate returnsfalse) or not (predicate returnstrue). Non-transient failures are never retried. In essence, this is just a failure typed variant ofnonTransientFailurePredicate(Predicate)method.- Type Parameters:
E- type of the failure to handle- Parameters:
failureType- concrete class of the failure to handlenonTransientFailurePredicate- aPredicate(accepting afailureTypeparameter) used for testing transiency of provided failure- Returns:
- the current Builder instance, for fluent interfacing
-
addNonTransientFailurePredicate
public B addNonTransientFailurePredicate(@Nonnull Predicate<Throwable> nonTransientFailurePredicate) Adds additional predicate into the predicate chain for checking non-transiency of a failure. ProvidednonTransientFailurePredicateis set on the beginning of the predicate chain with thePredicate#oroperator. -
addNonTransientFailurePredicate
public <E extends Throwable> B addNonTransientFailurePredicate(@Nonnull Class<E> failureType, @Nonnull Predicate<? super E> nonTransientFailurePredicate) Adds additional predicate into the predicate chain for checking non-transiency of a failure. ProvidednonTransientFailurePredicateis set on the beginning of the predicate chain withoroperator. In essence, this is just a failure typed variant ofaddNonTransientFailurePredicate(Predicate)method.- Type Parameters:
E- type of the failure to handle- Parameters:
failureType- concrete class of the failure to handlenonTransientFailurePredicate- an additionalPredicate(accepting afailureparameter) to be added into the predicate chain used for testing transiency of provided failure- Returns:
- the current Builder instance, for fluent interfacing
-
maxRetryCount
Sets the maximum number of retries allowed for a single command. Defaults to 1.- Parameters:
maxRetryCount- anintspecifying the maximum number of retries allowed for a single command- Returns:
- the current Builder instance, for fluent interfacing
-
validate
Validate the fields. This method is called in theAbstractRetryScheduler's constructor.- Throws:
AxonConfigurationException- if validation fails.
-