Class NonTransientExceptionClassesPredicate

java.lang.Object
org.axonframework.messaging.core.retry.NonTransientExceptionClassesPredicate
All Implemented Interfaces:
Predicate<Throwable>
Direct Known Subclasses:
AxonNonTransientExceptionClassesPredicate

public class NonTransientExceptionClassesPredicate extends Object implements Predicate<Throwable>
A predicate for checking non-transiency of a failure comparing it against configured concrete classes.

Comparison checks if any of configured classes is assignable from a tested failure instance.

This predicate is intended to be used for configuring RetryScheduler implementations like in the following example:

 AsyncRetryScheduler myRetryScheduler = AsyncRetryScheduler
      .builder()
      .retryExecutor(new ScheduledThreadPoolExecutor(1))
      .nonTransientFailurePredicate(
          new NonTransientExceptionClassesPredicate(
              AxonNonTransientException.class, NullPointerException.class, IllegalArgumentException.class,
              IllegalStateException.class
          )
      )
      .build();
 
Since:
4.6.0
Author:
Damir Murat
  • Constructor Details

    • NonTransientExceptionClassesPredicate

      @SafeVarargs public NonTransientExceptionClassesPredicate(Class<? extends Throwable>... nonTransientFailures)
      Initialize the predicate with class(es) that are considered as non-transient.
      Parameters:
      nonTransientFailures - vararg list of non-transient class(es)
  • Method Details

    • test

      public boolean test(Throwable failure)
      Specified by:
      test in interface Predicate<Throwable>
    • isNonTransientFailure

      protected boolean isNonTransientFailure(Throwable failure)
      Checks if the provided failure is considered non-transient.

      This implementation checks if any configured exception class is assignable to the provided failure.

      Parameters:
      failure - The failure to check for non-transiency
      Returns:
      a boolean indicating if provided failure is non-transient (true) or not (false)
    • getNonTransientFailures

      protected List<Class<? extends Throwable>> getNonTransientFailures()
      Fetches a configured list of non-transient failures.

      Useful if one wants to override isNonTransientFailure(Throwable).

      Returns:
      a configured list of non-transient failures.