Class WebsocketTrackingClient
- All Implemented Interfaces:
WebsocketEndpoint, 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.ClientHandshakeConfigurator, AbstractWebsocketClient.ConnectionSetup, AbstractWebsocketClient.PingRegistration, AbstractWebsocketClient.PreparedRequest<R>, AbstractWebsocketClient.WebSocketRequestNested classes/interfaces inherited from interface WebsocketEndpoint
WebsocketEndpoint.ReceiveTiming -
Field Summary
Fields inherited from class AbstractWebsocketClient
CLIENT_HANDSHAKE_CONFIGURATOR_USER_PROPERTY, CLIENT_SESSION_ID_USER_PROPERTY, CONNECTION_RETRY_LOG_INTERVAL, CONNECTION_TIMEOUT_FAILSAFE_GRACE, defaultObjectMapper, defaultWebsocketConnector, NEGOTIATED_SESSION_ID_USER_PROPERTY, RUNTIME_SESSION_ID_USER_PROPERTY, RUNTIME_VERSION_USER_PROPERTY, SELECTED_COMPRESSION_ALGORITHM_USER_PROPERTY, SELECTED_TRANSPORT_FORMAT_USER_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionWebsocketTrackingClient(String endPointUrl, WebSocketClient client, io.fluxzero.common.MessageType type, String topic) WebsocketTrackingClient(URI endPointUri, WebSocketClient client, io.fluxzero.common.MessageType type, String topic, boolean sendMetrics) -
Method Summary
Modifier and TypeMethodDescriptionprotected io.fluxzero.common.api.RequestadaptRequestForSession(io.fluxzero.common.api.Request request, WebsocketSession session) Adapts an outgoing request to the selected peer on every attempt, including reconnect replay.CompletableFuture<io.fluxzero.common.api.tracking.ClaimSegmentResult> claimSegment(String trackerId, Long lastIndex, ConsumerConfiguration config) Requests a tracker segment using this client's message type and the consumer's filtering, waiting, and index-control settings; returns the asynchronous claim result.voidclose()Closes any open resources associated with this client.disconnectTerminatedTracker(String consumer, String trackerId, io.fluxzero.common.Guarantee guarantee) Releases a terminated local tracker, including any abandoned asynchronous reads still completing.disconnectTracker(String consumer, String trackerId, boolean sendFinalEmptyBatch, io.fluxzero.common.Guarantee guarantee) Disconnects the specified tracker from its segment with the specified delivery guarantee.io.fluxzero.common.api.tracking.PositiongetPosition(String consumer) Returns the current committed tracking position for the given consumer.protected io.fluxzero.common.api.RequestResultlocalResponseForSession(io.fluxzero.common.api.Request request, WebsocketSession session) Returns a local response for a peer-specific no-op, or null when the request must be sent.protected io.fluxzero.common.api.Metadataprotected List<? extends io.fluxzero.common.websocket.WebSocketPayloadCodec> Returns compact payload codecs owned by this concrete protocol client.CompletableFuture<io.fluxzero.common.api.tracking.MessageBatch> read(String trackerId, Long lastIndex, ConsumerConfiguration configuration) Asynchronously reads the next availableMessageBatchfor a given tracker.List<io.fluxzero.common.api.SerializedMessage> readFromIndex(long minIndex, int maxSize) Fetches messages starting from the given index up to the provided max size.List<io.fluxzero.common.api.SerializedMessage> readFromIndex(long minIndex, int maxSize, long maxBytes) Fetches messages directly from the message log while limiting both message count and complete serialized bytes.resetPosition(String consumer, long lastIndex, io.fluxzero.common.Guarantee guarantee) Resets the consumer's tracking position to a given index with a specific delivery guarantee.storePosition(String consumer, int[] segment, long lastIndex, io.fluxzero.common.Guarantee guarantee) Stores the last successfully processed position for a consumer with a specific delivery guarantee.booleanWhether an established peer can filter consumer deliveries.toString()Methods inherited from class AbstractWebsocketClient
abort, canAwaitShutdownResults, captureReceiveTiming, close, connectToServer, connectToServer, createConnectionRetryConfiguration, createConnectionSetup, createConnectionSetup, getCloseHandshakeTimeout, getCompressionAlgorithm, getConnectionTimeoutFailsafeGrace, getNegotiatedSessionId, getRuntimeVersion, getTransportFormat, handleClose, handleError, handleMessage, handlePong, handleResult, handleResult, jfrResultType, logConnectionRetryStatus, logSuccessfulReconnect, maxRequestBatchSize, nextReconnectJitter, onClose, onError, onMessage, onMessage, onOpen, onPong, outstandingRequest, pendingResponses, prepareRequest, prepareRequest, prepareResults, resolveGuarantee, restoreResultContext, restoreResultContext, retryOutstandingRequests, retryOutstandingRequestsAsync, retryOutstandingRequestsDelay, schedulePing, send, send, sendAndWait, sendCommand, sendPing, sendPreparedRequests, sendToAllSessions, sessionsForCapabilities, startRequestBatchEvent, transportCodec, transportMetricPublicationTimeout, tryPublishMetricsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface TrackingClient
disconnectTracker, getMessageType, getTopic, readAndWait, readRange, readRange, resetPosition, storePosition
-
Constructor Details
-
WebsocketTrackingClient
public WebsocketTrackingClient(String endPointUrl, WebSocketClient client, io.fluxzero.common.MessageType type, String topic) -
WebsocketTrackingClient
public WebsocketTrackingClient(URI endPointUri, WebSocketClient client, io.fluxzero.common.MessageType type, String topic, boolean sendMetrics)
-
-
Method Details
-
payloadCodecs
Description copied from class:AbstractWebsocketClientReturns compact payload codecs owned by this concrete protocol client.- Overrides:
payloadCodecsin classAbstractWebsocketClient
-
supportsConsumerFiltering
public boolean supportsConsumerFiltering()Description copied from interface:TrackingClientWhether an established peer can filter consumer deliveries. Custom clients conservatively default to false; websocket implementations may establish their first connection to discover this capability.- Specified by:
supportsConsumerFilteringin interfaceTrackingClient
-
adaptRequestForSession
protected io.fluxzero.common.api.Request adaptRequestForSession(io.fluxzero.common.api.Request request, WebsocketSession session) Description copied from class:AbstractWebsocketClientAdapts an outgoing request to the selected peer on every attempt, including reconnect replay.- Overrides:
adaptRequestForSessionin classAbstractWebsocketClient
-
localResponseForSession
protected io.fluxzero.common.api.RequestResult localResponseForSession(io.fluxzero.common.api.Request request, WebsocketSession session) Description copied from class:AbstractWebsocketClientReturns a local response for a peer-specific no-op, or null when the request must be sent.- Overrides:
localResponseForSessionin classAbstractWebsocketClient
-
read
public CompletableFuture<io.fluxzero.common.api.tracking.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<io.fluxzero.common.api.tracking.ClaimSegmentResult> claimSegment(String trackerId, Long lastIndex, ConsumerConfiguration config) Requests a tracker segment using this client's message type and the consumer's filtering, waiting, and index-control settings; returns the asynchronous claim result.- 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
-
readFromIndex
public List<io.fluxzero.common.api.SerializedMessage> readFromIndex(long minIndex, int maxSize, long maxBytes) Description copied from interface:TrackingClientFetches messages directly from the message log while limiting both message count and complete serialized bytes.If the first available message is larger than
maxBytes, it is still returned so consumers can make progress. AmaxBytesvalue of0disables the byte limit.- Specified by:
readFromIndexin interfaceTrackingClient- Parameters:
minIndex- the starting index (inclusive)maxSize- the maximum number of messages to retrievemaxBytes- the maximum number of complete serialized message bytes to retrieve- Returns:
- a list of serialized messages starting at the given index
-
storePosition
public CompletableFuture<Void> storePosition(String consumer, int[] segment, long lastIndex, io.fluxzero.common.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
public CompletableFuture<Void> resetPosition(String consumer, long lastIndex, io.fluxzero.common.Guarantee guarantee) 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, io.fluxzero.common.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
-
disconnectTerminatedTracker
public CompletableFuture<Void> disconnectTerminatedTracker(String consumer, String trackerId, io.fluxzero.common.Guarantee guarantee) Description copied from interface:TrackingClientReleases a terminated local tracker, including any abandoned asynchronous reads still completing. The caller must have finished processing and must not issue further reads with this tracker identity. Wrappers that can initiate follow-up reads should override this method to release after those reads as well. This does not change the semantics of a temporaryTrackingClient.disconnectTracker(String, String, boolean).- Specified by:
disconnectTerminatedTrackerin interfaceTrackingClient
-
metricsMetadata
protected io.fluxzero.common.api.Metadata 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
-