Class SegmentMatcher
java.lang.Object
org.axonframework.messaging.eventhandling.processing.streaming.segmenting.SegmentMatcher
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 Summary
ConstructorsConstructorDescriptionSegmentMatcher(SequencingPolicy sequencingPolicy) Initialize a SegmentMatcher with the givensequencingPolicy. -
Method Summary
Modifier and TypeMethodDescriptionbooleanmatches(Segment segment, EventMessage event, ProcessingContext context) Checks whether the givensegmentmatches the givenevent, based on the configured sequencing policy.sequenceIdentifier(EventMessage event, ProcessingContext context) Returns the sequence identifier for the givenevent, as defined by the configured sequencing policy.
-
Constructor Details
-
SegmentMatcher
Initialize a SegmentMatcher with the givensequencingPolicy. 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(@Nonnull Segment segment, @Nonnull EventMessage event, @Nonnull ProcessingContext context) Checks whether the givensegmentmatches the givenevent, 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:
trueif the event matches the segment,falseotherwise.
-
sequenceIdentifier
Returns the sequence identifier for the givenevent, as defined by the configured sequencing policy. If the policy returnsnull, 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.
-