java.lang.Object
org.axonframework.messaging.eventhandling.processing.streaming.segmenting.SegmentMatcher

@Internal public class SegmentMatcher extends Object
Utility class that matches EventMessages against a Segment based on a SequencingPolicy.

This class uses the sequencing policy to determine the sequence identifier for a message, and then checks if that identifier matches the given segment.

Since:
5.0.0
Author:
Mateusz Nowak
  • Constructor Details

    • SegmentMatcher

      public SegmentMatcher(SequencingPolicy<? super EventMessage> sequencingPolicy)
      Initialize a SegmentMatcher with the given sequencingPolicy. This policy is used to extract the sequence identifier from messages, which is then used to match against segments.
      Parameters:
      sequencingPolicy - A policy that provides the sequence identifier for a given event message.
  • Method Details

    • matches

      public boolean matches(Segment segment, EventMessage event, ProcessingContext context)
      Checks whether the given segment matches the given event, based on the configured sequencing policy.
      Parameters:
      segment - The segment to match against.
      event - The event to check.
      context - The processing context in which the event is being handled.
      Returns:
      true if the event matches the segment, false otherwise.
    • sequenceIdentifier

      public Object sequenceIdentifier(EventMessage event, ProcessingContext context)
      Returns the sequence identifier for the given event, as defined by the configured sequencing policy. If the policy returns null, the event's identifier is used as a fallback.
      Parameters:
      event - The event to get the sequence identifier for.
      context - The processing context in which the event is being handled.
      Returns:
      The sequence identifier for the event, never null.