Class HierarchicalSequencingPolicy<M extends Message>

java.lang.Object
org.axonframework.messaging.core.sequencing.HierarchicalSequencingPolicy<M>
Type Parameters:
M - the type of message to sequence
All Implemented Interfaces:
SequencingPolicy<M>

public class HierarchicalSequencingPolicy<M extends Message> extends Object implements SequencingPolicy<M>
Implementation of SequencingPolicy that combines two policies in a fallback pattern. When the primary policy fails to determine a sequence identifier for a message (returns Optional.empty()), this implementation will delegate to a secondary fallback policy.

This allows for composing sequencing strategies where certain message types might be handled by specialized policies, falling back to more generic approaches when specialized sequencing fails.

Since:
5.0.0
Author:
Mateusz Nowak
  • Constructor Details

    • HierarchicalSequencingPolicy

      public HierarchicalSequencingPolicy(SequencingPolicy<? super M> primary, SequencingPolicy<? super M> secondary)
      Initializes a new instance with the given primary delegate and fallback policies.
      Parameters:
      primary - The primary policy to attempt sequence identification with first, not null.
      secondary - The fallback policy to use when the delegate fails, not null.
      Throws:
      NullPointerException - When either the delegate or fallback is null.
  • Method Details