Class AbstractClient
java.lang.Object
io.fluxzero.sdk.configuration.client.AbstractClient
- All Implemented Interfaces:
Namespaced<Client>, 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) Fluxzero 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 TypeMethodDescriptionbeforeShutdown(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(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(MessageType messageType, String topic) Subclasses must implement this method to return aTrackingClientfor the given message type and topic.getGatewayClient(MessageType messageType, String topic) Returns the memoizedGatewayClientfor the given message type and topic.getTrackingClient(MessageType messageType, String topic) Returns aTrackingClientfor the given message type and topic.monitorDispatch(ClientDispatchMonitor monitor, 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Client
applicationId, getEventStoreClient, getGatewayClient, getKeyValueClient, getSchedulingClient, getSearchClient, getTrackingClient, id, name, namespace, unwrapMethods inherited from interface Namespaced
forDefaultNamespace, forNamespace
-
Field Details
-
shutdownTasks
Tracks shutdown callbacks that will be run whenshutDown()is invoked.
-
-
Constructor Details
-
AbstractClient
public AbstractClient()
-
-
Method Details
-
createGatewayClient
Subclasses must implement this method to return aGatewayClientfor the given message type and topic. -
createTrackingClient
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
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
-
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
-