Class SegmentFilter

java.lang.Object
io.fluxzero.sdk.tracking.handling.SegmentFilter

public class SegmentFilter extends Object
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 RoutingKey annotation 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 returns true.

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 Details

    • SegmentFilter

      public SegmentFilter()
  • Method Details