java.lang.Object
io.fluxzero.sdk.configuration.client.AbstractClient
- All Implemented Interfaces:
Client
- Direct Known Subclasses:
LocalClient,WebSocketClient
Abstract base implementation of the
Client interface, providing shared logic and lifecycle management for
both local (in-memory) and remote (WebSocket-based) Flux clients.
Concrete implementations such as LocalClient and WebSocketClient extend this class to define specific
transport and storage mechanisms for each subsystem (event store, scheduling, etc.).
Responsibilities
- Manages memoized creation and reuse of
GatewayClientandTrackingClientinstances. - Coordinates shutdown behavior and cleanup tasks via
shutDown()andbeforeShutdown(Runnable). - Provides monitoring support for dispatched messages using
ClientDispatchMonitor.
-
Field Summary
FieldsModifier and TypeFieldDescriptionTracks shutdown callbacks that will be run whenshutDown()is invoked. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.fluxzero.common.RegistrationbeforeShutdown(Runnable task) Registers a shutdown hook that will be called before this client shuts down.protected abstract EventStoreClientSubclasses must implement this method to return aEventStoreClient.protected abstract GatewayClientcreateGatewayClient(io.fluxzero.common.MessageType messageType, String topic) Subclasses must implement this method to return aGatewayClientfor the given message type and topic.protected abstract KeyValueClientSubclasses must implement this method to return aKeyValueClient.protected abstract SchedulingClientSubclasses must implement this method to return aSchedulingClient.protected abstract SearchClientSubclasses must implement this method to return aSearchClient.protected abstract TrackingClientcreateTrackingClient(io.fluxzero.common.MessageType messageType, String topic) Subclasses must implement this method to return aTrackingClientfor the given message type and topic.getGatewayClient(io.fluxzero.common.MessageType messageType, String topic) Returns the memoizedGatewayClientfor the given message type and topic.getTrackingClient(io.fluxzero.common.MessageType messageType, String topic) Returns aTrackingClientfor the given message type and topic.io.fluxzero.common.RegistrationmonitorDispatch(ClientDispatchMonitor monitor, io.fluxzero.common.MessageType... messageTypes) Registers aClientDispatchMonitorto receive hooks and diagnostics when messages of the givenMessageTypes are dispatched from this client.voidshutDown()Shuts down this client instance, releasing any underlying resources.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.fluxzero.sdk.configuration.client.Client
applicationId, getEventStoreClient, getGatewayClient, getKeyValueClient, getSchedulingClient, getSearchClient, getTrackingClient, id, name, unwrap
-
Field Details
-
shutdownTasks
Tracks shutdown callbacks that will be run whenshutDown()is invoked.
-
-
Constructor Details
-
AbstractClient
public AbstractClient()
-
-
Method Details
-
createGatewayClient
protected abstract GatewayClient createGatewayClient(io.fluxzero.common.MessageType messageType, String topic) Subclasses must implement this method to return aGatewayClientfor the given message type and topic. -
createTrackingClient
protected abstract TrackingClient createTrackingClient(io.fluxzero.common.MessageType messageType, String topic) Subclasses must implement this method to return aTrackingClientfor the given message type and topic. -
createEventStoreClient
Subclasses must implement this method to return aEventStoreClient. -
createSchedulingClient
Subclasses must implement this method to return aSchedulingClient. -
createKeyValueClient
Subclasses must implement this method to return aKeyValueClient. -
createSearchClient
Subclasses must implement this method to return aSearchClient. -
getGatewayClient
Returns the memoizedGatewayClientfor the given message type and topic. Automatically registers any previously registeredClientDispatchMonitorinstances.- Specified by:
getGatewayClientin interfaceClient- Parameters:
messageType- the type of message (e.g. COMMAND, EVENT, etc.)topic- the topic to publish messages to (may benullfor default)
-
monitorDispatch
public io.fluxzero.common.Registration monitorDispatch(ClientDispatchMonitor monitor, io.fluxzero.common.MessageType... messageTypes) Description copied from interface:ClientRegisters aClientDispatchMonitorto receive hooks and diagnostics when messages of the givenMessageTypes are dispatched from this client.- Specified by:
monitorDispatchin interfaceClient- Parameters:
monitor- the dispatch monitor to registermessageTypes- the message types to monitor- Returns:
- a
Registrationhandle to remove the monitor
-
getTrackingClient
Description copied from interface:ClientReturns aTrackingClientfor the given message type and topic.- Specified by:
getTrackingClientin interfaceClient- Parameters:
messageType- the type of message to track (e.g. COMMAND, EVENT, QUERY)topic- the topic to track messages from (may benullfor default)
-
shutDown
public void shutDown()Description copied from interface:ClientShuts down this client instance, releasing any underlying resources.This includes closing websocket sessions, stopping tracking, and executing registered shutdown hooks.
-
beforeShutdown
Description copied from interface:ClientRegisters a shutdown hook that will be called before this client shuts down.- Specified by:
beforeShutdownin interfaceClient- Parameters:
task- the action to invoke before shutdown- Returns:
- a
Registrationto remove the task
-