Class WebsocketTrackingClient
- All Implemented Interfaces:
TrackingClient, AutoCloseable
TrackingClient that connects to the Fluxzero Runtime.
All tracking-related operations—including reading messages, claiming segments, storing/resetting positions, and disconnecting trackers—are performed via a standardized WebSocket protocol with the Fluxzero Runtime.
This is the default production implementation used in deployed applications to track message streams such as commands, queries, events, and other custom message types.
Requires an active WebSocket connection to the Fluxzero Runtime’s tracking service.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractWebsocketClient
AbstractWebsocketClient.PingRegistration, AbstractWebsocketClient.WebSocketRequest -
Field Summary
Fields inherited from class AbstractWebsocketClient
defaultObjectMapper, defaultWebSocketContainer -
Constructor Summary
ConstructorsConstructorDescriptionWebsocketTrackingClient(String endPointUrl, WebSocketClient client, MessageType type, String topic) WebsocketTrackingClient(URI endPointUri, WebSocketClient client, MessageType type, String topic, boolean sendMetrics) -
Method Summary
Modifier and TypeMethodDescriptionclaimSegment(String trackerId, Long lastIndex, ConsumerConfiguration config) Claims a processing segment for the given tracker.voidclose()Closes any open resources associated with this client.disconnectTracker(String consumer, String trackerId, boolean sendFinalEmptyBatch, Guarantee guarantee) Disconnects the specified tracker from its segment with the specified delivery guarantee.getPosition(String consumer) Returns the current committed tracking position for the given consumer.protected Metadataread(String trackerId, Long lastIndex, ConsumerConfiguration configuration) Asynchronously reads the next availableMessageBatchfor a given tracker.readFromIndex(long minIndex, int maxSize) Fetches messages starting from the given index up to the provided max size.resetPosition(String consumer, long lastIndex, Guarantee guarantee) Resets the consumer's tracking position to a given index with a specific delivery guarantee.storePosition(String consumer, int[] segment, long lastIndex, Guarantee guarantee) Stores the last successfully processed position for a consumer with a specific delivery guarantee.toString()Methods inherited from class AbstractWebsocketClient
abort, close, handleResult, onClose, onError, onMessage, onOpen, onPong, retryOutstandingRequests, schedulePing, send, sendAndWait, sendCommand, sendPing, tryPublishMetricsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface TrackingClient
disconnectTracker, getMessageType, getTopic, readAndWait, resetPosition, storePosition
-
Constructor Details
-
WebsocketTrackingClient
public WebsocketTrackingClient(String endPointUrl, WebSocketClient client, MessageType type, String topic) -
WebsocketTrackingClient
public WebsocketTrackingClient(URI endPointUri, WebSocketClient client, MessageType type, String topic, boolean sendMetrics)
-
-
Method Details
-
read
public CompletableFuture<MessageBatch> read(String trackerId, Long lastIndex, ConsumerConfiguration configuration) Description copied from interface:TrackingClientAsynchronously reads the next availableMessageBatchfor a given tracker.- Specified by:
readin interfaceTrackingClient- Parameters:
trackerId- the unique ID for the tracker thread requesting messageslastIndex- the last index successfully handled by this trackerconfiguration- the full configuration for the consumer- Returns:
- a
CompletableFuturethat completes with the next batch of messages
-
claimSegment
public CompletableFuture<ClaimSegmentResult> claimSegment(String trackerId, Long lastIndex, ConsumerConfiguration config) Description copied from interface:TrackingClientClaims a processing segment for the given tracker.Segments are used to partition the message log among multiple tracker threads for parallel processing.
- Specified by:
claimSegmentin interfaceTrackingClient- Parameters:
trackerId- the unique identifier of the tracker attempting to claim a segmentlastIndex- the tracker's last successfully processed indexconfig- the full consumer configuration- Returns:
- a
CompletableFutureresolving to the result of the claim
-
readFromIndex
Description copied from interface:TrackingClientFetches messages starting from the given index up to the provided max size.This method bypasses consumer configurations and is primarily used for diagnostics or reprocessing.
- Specified by:
readFromIndexin interfaceTrackingClient- Parameters:
minIndex- the starting index (inclusive)maxSize- the maximum number of messages to retrieve- Returns:
- a list of serialized messages starting at the given index
-
storePosition
public CompletableFuture<Void> storePosition(String consumer, int[] segment, long lastIndex, Guarantee guarantee) Description copied from interface:TrackingClientStores the last successfully processed position for a consumer with a specific delivery guarantee.- Specified by:
storePositionin interfaceTrackingClient- Parameters:
consumer- the name of the consumersegment- the segment the tracker is processinglastIndex- the last message index processedguarantee- delivery guarantee (e.g., STORED, SENT)- Returns:
- a future indicating completion
-
resetPosition
Description copied from interface:TrackingClientResets the consumer's tracking position to a given index with a specific delivery guarantee.- Specified by:
resetPositionin interfaceTrackingClient- Parameters:
consumer- the name of the consumerlastIndex- the new index to start fromguarantee- the delivery guarantee- Returns:
- a future indicating completion
-
getPosition
Description copied from interface:TrackingClientReturns the current committed tracking position for the given consumer.- Specified by:
getPositionin interfaceTrackingClient- Parameters:
consumer- the name of the consumer- Returns:
- the last known committed position
-
disconnectTracker
public CompletableFuture<Void> disconnectTracker(String consumer, String trackerId, boolean sendFinalEmptyBatch, Guarantee guarantee) Description copied from interface:TrackingClientDisconnects the specified tracker from its segment with the specified delivery guarantee.- Specified by:
disconnectTrackerin interfaceTrackingClient- Parameters:
consumer- the name of the consumer grouptrackerId- the ID of the tracker thread being disconnectedsendFinalEmptyBatch- whether to send a final empty batch to commit stateguarantee- the delivery guarantee to use- Returns:
- a future indicating disconnection
-
metricsMetadata
- Overrides:
metricsMetadatain classAbstractWebsocketClient
-
close
public void close()Description copied from interface:TrackingClientCloses any open resources associated with this client.Once closed, the client should no longer be used to fetch or commit tracking state.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceTrackingClient- Overrides:
closein classAbstractWebsocketClient
-
toString
- Overrides:
toStringin classAbstractWebsocketClient
-