Interface Client
- All Known Implementing Classes:
AbstractClient
,LocalClient
,WebSocketClient
FluxCapacitorBuilder
to construct a
FluxCapacitor
instance.
Application developers must provide an implementation of this interface to the
FluxCapacitorBuilder.build(Client)
method. This allows for flexible configuration, enabling either an
in-memory setup (useful for testing and local development) or a connected (WebSocket-based) client that integrates
with the Flux Platform.
Client Implementations
Common implementations include:LocalClient
— for local, standalone useWebSocketClient
— connects to the Flux Platform using WebSockets
Responsibilities
AClient
implementation is responsible for:
- Providing access to gateway and tracking subsystems via
GatewayClient
andTrackingClient
- Managing subsystems for event storage, scheduling, key-value access, and search
- Handling client shutdown via
shutDown()
and shutdown hooks - Optionally monitoring dispatches via
monitorDispatch(ClientDispatchMonitor, MessageType...)
Usage
Client client = LocalClient.newInstance();
FluxCapacitor fluxCapacitor = FluxCapacitorBuilder.newInstance().build(client);
-
Method Summary
Modifier and TypeMethodDescriptionReturns the application ID under which this client instance is registered.beforeShutdown
(Runnable task) Registers a shutdown hook that will be called before this client shuts down.Returns theEventStoreClient
associated with this client for querying event logs.default GatewayClient
getGatewayClient
(MessageType messageType) Returns aGatewayClient
for the given message type using the default topic (typicallynull
).getGatewayClient
(MessageType messageType, String topic) Returns aGatewayClient
for the given message type and topic.Returns theKeyValueClient
for key-value store interactions.Returns theSchedulingClient
used to interact with the Flux scheduling subsystem.Returns theSearchClient
that provides access to document and search APIs.default TrackingClient
getTrackingClient
(MessageType messageType) Returns aTrackingClient
for the given message type using the default topic.getTrackingClient
(MessageType messageType, String topic) Returns aTrackingClient
for the given message type and topic.id()
Returns the unique identifier of this client instance.monitorDispatch
(ClientDispatchMonitor monitor, MessageType... messageTypes) Registers aClientDispatchMonitor
to receive hooks and diagnostics when messages of the givenMessageType
s are dispatched from this client.name()
Returns the name of this client as defined in its configuration.void
shutDown()
Shuts down this client instance, releasing any underlying resources.default Client
unwrap()
Returns the underlyingClient
implementation.
-
Method Details
-
name
String name()Returns the name of this client as defined in its configuration. -
id
String id()Returns the unique identifier of this client instance. This id may be randomly generated. -
applicationId
String applicationId()Returns the application ID under which this client instance is registered. -
getGatewayClient
Returns aGatewayClient
for the given message type using the default topic (typicallynull
).For
MessageType.DOCUMENT
orMessageType.CUSTOM
, this method is not supported and will throw anUnsupportedOperationException
, as these require a topic.- Parameters:
messageType
- the type of message gateway- Returns:
- the associated
GatewayClient
- Throws:
UnsupportedOperationException
- if the message type requires a topic
-
getGatewayClient
Returns aGatewayClient
for the given message type and topic.- Parameters:
messageType
- the type of message (e.g. COMMAND, EVENT, etc.)topic
- the topic to publish messages to (may benull
for default)
-
monitorDispatch
Registers aClientDispatchMonitor
to receive hooks and diagnostics when messages of the givenMessageType
s are dispatched from this client.- Parameters:
monitor
- the dispatch monitor to registermessageTypes
- the message types to monitor- Returns:
- a
Registration
handle to remove the monitor
-
getTrackingClient
Returns aTrackingClient
for the given message type using the default topic.For
MessageType.DOCUMENT
orMessageType.CUSTOM
, this method is not supported and will throw anUnsupportedOperationException
.- Parameters:
messageType
- the type of message to track- Returns:
- the associated
TrackingClient
- Throws:
UnsupportedOperationException
- if the message type requires a topic
-
getTrackingClient
Returns aTrackingClient
for the given message type and topic.- Parameters:
messageType
- the type of message to track (e.g. COMMAND, EVENT, QUERY)topic
- the topic to track messages from (may benull
for default)
-
getEventStoreClient
EventStoreClient getEventStoreClient()Returns theEventStoreClient
associated with this client for querying event logs. -
getSchedulingClient
SchedulingClient getSchedulingClient()Returns theSchedulingClient
used to interact with the Flux scheduling subsystem. -
getKeyValueClient
KeyValueClient getKeyValueClient()Returns theKeyValueClient
for key-value store interactions.This is mostly deprecated and maintained for backward compatibility.
-
getSearchClient
SearchClient getSearchClient()Returns theSearchClient
that provides access to document and search APIs. -
shutDown
void shutDown()Shuts down this client instance, releasing any underlying resources.This includes closing websocket sessions, stopping tracking, and executing registered shutdown hooks.
-
beforeShutdown
Registers a shutdown hook that will be called before this client shuts down.- Parameters:
task
- the action to invoke before shutdown- Returns:
- a
Registration
to remove the task
-
unwrap
Returns the underlyingClient
implementation. This is a convenience method to allow clients to explicitly unwrap proxies or decorators.- Returns:
- the concrete
Client
instance (oftenthis
itself)
-