java.lang.Object
io.fluxzero.sdk.tracking.handling.SegmentFilter
- All Implemented Interfaces:
io.fluxzero.common.handling.MessageFilter<HasMessage>
public class SegmentFilter
extends Object
implements io.fluxzero.common.handling.MessageFilter<HasMessage>
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 TypeMethodDescriptionbooleantest(HasMessage message, Executable executable, Class<? extends Annotation> handlerAnnotation) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.fluxzero.common.handling.MessageFilter
and, getLeastSpecificAllowedClass
-
Constructor Details
-
SegmentFilter
public SegmentFilter()
-
-
Method Details
-
test
public boolean test(HasMessage message, Executable executable, Class<? extends Annotation> handlerAnnotation) - Specified by:
testin interfaceio.fluxzero.common.handling.MessageFilter<HasMessage>
-