Class DefaultTrackingStrategy

java.lang.Object
io.fluxzero.common.tracking.DefaultTrackingStrategy
All Implemented Interfaces:
TrackingStrategy, Closeable, AutoCloseable

public class DefaultTrackingStrategy extends Object implements TrackingStrategy
Streaming strategy that allows multiple clients to concurrently consume a message stream. Messages are routed to clients based on the value of their segment. Each connected client handles a distinct range of segments.

Message segments are determined by the clients that publish the messages (usually based on the consistent hash of some routing key, like the value of a user id).

If a client joins or leaves the cluster the segment range mapped to each client is recalculated so messages may get routed differently than before.

Clients can safely join or leave the cluster at any time. The strategy guarantees that a message is not consumed by more than one client.