Class SegmentFilter
java.lang.Object
io.fluxzero.sdk.tracking.handling.SegmentFilter
A
MessageFilter that restricts handler invocation based on segment membership, using routing keys.
This filter applies **only** when client-side segment filtering is enabled via the ignoreSegment = true
setting in the ConsumerConfiguration or Consumer. In such scenarios, handlers annotated with
RoutingKey will be evaluated to ensure that only messages matching the local segment range are processed by
the client.
When active, the filter performs the following logic:
- Extracts the routing key for the message using the
RoutingKeyannotation on the handler method. If the annotation is missing or the routing key cannot be resolved, the message ID is used as a fallback. - Delegates to
Tracker.canHandle(DeserializingMessage, String)to check whether the message falls within the current client's segment range. - If the message is not an instance of
DeserializingMessage, the filter always returnstrue.
This ensures that trackers that use client-side message filtering do not redundantly handle messages that don't fall within the tracker's segment range, ensuring that each message is handled only once in a distributed system.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondefault io.fluxzero.common.handling.MessageFilter<HasMessage> and(@NonNull io.fluxzero.common.handling.MessageFilter<? super HasMessage> arg0) getLeastSpecificAllowedClass(Executable arg0, Class<? extends Annotation> arg1) booleantest(HasMessage message, Executable executable, Class<? extends Annotation> handlerAnnotation)
-
Constructor Details
-
SegmentFilter
public SegmentFilter()
-
-
Method Details
-
test
public boolean test(HasMessage message, Executable executable, Class<? extends Annotation> handlerAnnotation) -
getLeastSpecificAllowedClass
default Optional<Class<?>> getLeastSpecificAllowedClass(Executable arg0, Class<? extends Annotation> arg1) -
and
default io.fluxzero.common.handling.MessageFilter<HasMessage> and(@NonNull @NonNull io.fluxzero.common.handling.MessageFilter<? super HasMessage> arg0)
-