Class AbstractClient
java.lang.Object
io.fluxcapacitor.javaclient.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
GatewayClient
andTrackingClient
instances. - 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 EventStoreClient
Subclasses must implement this method to return aEventStoreClient
.protected abstract GatewayClient
createGatewayClient
(MessageType messageType, String topic) Subclasses must implement this method to return aGatewayClient
for the given message type and topic.protected abstract KeyValueClient
Subclasses must implement this method to return aKeyValueClient
.protected abstract SchedulingClient
Subclasses must implement this method to return aSchedulingClient
.protected abstract SearchClient
Subclasses must implement this method to return aSearchClient
.protected abstract TrackingClient
createTrackingClient
(MessageType messageType, String topic) Subclasses must implement this method to return aTrackingClient
for the given message type and topic.getGatewayClient
(MessageType messageType, String topic) Returns the memoizedGatewayClient
for the given message type and topic.getTrackingClient
(MessageType messageType, String topic) Returns aTrackingClient
for the given message type and topic.monitorDispatch
(ClientDispatchMonitor monitor, MessageType... messageTypes) Registers aClientDispatchMonitor
to receive hooks and diagnostics when messages of the givenMessageType
s are dispatched from this client.void
shutDown()
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, wait
Methods inherited from interface io.fluxcapacitor.javaclient.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
Subclasses must implement this method to return aGatewayClient
for the given message type and topic. -
createTrackingClient
Subclasses must implement this method to return aTrackingClient
for 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 memoizedGatewayClient
for the given message type and topic. Automatically registers any previously registeredClientDispatchMonitor
instances.- Specified by:
getGatewayClient
in interfaceClient
- Parameters:
messageType
- the type of message (e.g. COMMAND, EVENT, etc.)topic
- the topic to publish messages to (may benull
for default)
-
monitorDispatch
Description copied from interface:Client
Registers aClientDispatchMonitor
to receive hooks and diagnostics when messages of the givenMessageType
s are dispatched from this client.- Specified by:
monitorDispatch
in interfaceClient
- Parameters:
monitor
- the dispatch monitor to registermessageTypes
- the message types to monitor- Returns:
- a
Registration
handle to remove the monitor
-
getTrackingClient
Description copied from interface:Client
Returns aTrackingClient
for the given message type and topic.- Specified by:
getTrackingClient
in interfaceClient
- Parameters:
messageType
- the type of message to track (e.g. COMMAND, EVENT, QUERY)topic
- the topic to track messages from (may benull
for default)
-
shutDown
public void shutDown()Description copied from interface:Client
Shuts 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:Client
Registers a shutdown hook that will be called before this client shuts down.- Specified by:
beforeShutdown
in interfaceClient
- Parameters:
task
- the action to invoke before shutdown- Returns:
- a
Registration
to remove the task
-