Class FallbackSequencingPolicy<E extends Exception,M extends Message>

java.lang.Object
org.axonframework.messaging.core.sequencing.FallbackSequencingPolicy<E,M>
Type Parameters:
E - the type of exception to catch and handle
M - the type of message to sequence
All Implemented Interfaces:
SequencingPolicy<M>

public class FallbackSequencingPolicy<E extends Exception,M extends Message> extends Object implements SequencingPolicy<M>
Implementation of SequencingPolicy that provides exception-based fallback behavior. When the delegate policy throws a specified exception type, this implementation will catch it and delegate to a fallback policy.

This allows for composing sequencing strategies where certain policies might fail with exceptions for unsupported message types, falling back to more generic approaches when exceptions occur.

Since:
5.0.0
Author:
Mateusz Nowak
  • Constructor Details

    • FallbackSequencingPolicy

      public FallbackSequencingPolicy(SequencingPolicy<? super M> delegate, SequencingPolicy<? super M> fallback, Class<E> exceptionType)
      Initializes a new instance with the given delegate policy, fallback policy, and exceptionType to catch.
      Parameters:
      delegate - The primary policy to attempt sequence identification with first, not null.
      fallback - The fallback policy to use when the delegate throws the specified exception, not null.
      exceptionType - The type of exception to catch from the delegate policy, not null.
      Throws:
      NullPointerException - When any of the parameters is null.
  • Method Details