Class LocalClient
java.lang.Object
io.fluxzero.sdk.common.AbstractNamespaced<Client>
io.fluxzero.sdk.configuration.client.AbstractClient
io.fluxzero.sdk.configuration.client.LocalClient
- All Implemented Interfaces:
Namespaced<Client>, Client
An in-memory
Client implementation used for local development, testing, or isolated environments where no
connection to the Fluxzero Runtime is required.
This client simulates all major subsystems — including event storage, scheduling, key-value access, and document search — using in-memory data structures with optional message expiration. It is ideal for use cases such as:
- Unit testing message handlers
- Running local development instances without Fluxzero Runtime dependencies
- Offline simulations and demos
Configuration
The default expiration time for messages and scheduled tasks is 2 minutes, but a custom duration can be specified:LocalClient client = LocalClient.newInstance(Duration.ofMinutes(5));
Features
- Simulates gateway clients for all
MessageTypes - Provides in-memory implementations of event store, scheduling, key-value, and search clients
- Uses the
FLUXZERO_TASK_IDenvironment property or the JVM process name as its local-only ID - Reads
FLUXZERO_APPLICATION_NAMEandFLUXZERO_APPLICATION_IDfrom environment or system properties
Usage
Typical usage involves passing this client into theFluxzeroBuilder:
Fluxzero fluxzero = DefaultFluxzero.builder().build(LocalClient.newInstance());
-
Field Summary
Fields inherited from class AbstractClient
shutdownTasks -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLocalClient(Duration messageExpiration) protectedLocalClient(Duration messageExpiration, String namespace, LocalClient applicationClient, Clock clock) protectedLocalClient(Duration messageExpiration, Duration initialPositionLag) protectedLocalClient(Duration messageExpiration, Duration initialPositionLag, String namespace, LocalClient applicationClient, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionReturns the application ID under which this client instance is registered.protected EventStoreClientSubclasses must implement this method to return aEventStoreClient.protected ClientcreateForNamespace(String namespace) protected GatewayClientcreateGatewayClient(io.fluxzero.common.MessageType messageType, String topic) Subclasses must implement this method to return aGatewayClientfor the given message type and topic.protected KeyValueClientSubclasses must implement this method to return aKeyValueClient.protected SchedulingClientSubclasses must implement this method to return aSchedulingClient.protected InMemorySearchStoreSubclasses must implement this method to return aSearchClient.protected TrackingClientcreateTrackingClient(io.fluxzero.common.MessageType messageType, String topic) Subclasses must implement this method to return aTrackingClientfor the given message type and topic.Returns a sorted, duplicate-free snapshot of namespaces in this client's storage environment.name()Returns the name of this client as defined in its configuration.static LocalClientCreates an in-memory client usingFLUXZERO_LOG_RETENTIONfrom application properties, defaulting to two minutes of message retention.static LocalClientnewInstance(Duration messageExpiration) Creates an in-memory client with the supplied message-retention duration.static LocalClientnewInstance(Duration messageExpiration, Duration initialPositionLag) Creates a local client with configurable message retention and initial look-back for new consumers.voidLinks the local scheduling store to the Fluxzero clock.Methods inherited from class AbstractClient
beforeShutdown, getGatewayClient, getTrackingClient, knownNamespaces, monitorDispatch, registerNamespaceClient, shutDownMethods inherited from class AbstractNamespaced
close, forNamespaceMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Client
getEventStoreClient, getGatewayClient, getKeyValueClient, getSchedulingClient, getSearchClient, getTrackingClient, id, namespace, unwrapMethods inherited from interface Namespaced
forApplicationNamespace, forDefaultNamespace, forNamespace
-
Constructor Details
-
LocalClient
-
LocalClient
-
LocalClient
protected LocalClient(Duration messageExpiration, String namespace, LocalClient applicationClient, Clock clock) -
LocalClient
protected LocalClient(Duration messageExpiration, Duration initialPositionLag, String namespace, LocalClient applicationClient, Clock clock)
-
-
Method Details
-
newInstance
Creates an in-memory client usingFLUXZERO_LOG_RETENTIONfrom application properties, defaulting to two minutes of message retention. -
newInstance
Creates an in-memory client with the supplied message-retention duration. -
newInstance
Creates a local client with configurable message retention and initial look-back for new consumers.- Parameters:
messageExpiration- retention duration for local messagesinitialPositionLag- duration subtracted from the current time for consumers without a stored position- Returns:
- a new local client
-
setClock
Links the local scheduling store to the Fluxzero clock.This is called by the Fluxzero builder so local schedules and test-time shifts observe the same time source as the rest of the SDK.
-
getNamespaces
Description copied from interface:ClientReturns a sorted, duplicate-free snapshot of namespaces in this client's storage environment. The Runtime includes persisted namespaces without active clients. Local clients include namespaces created within the same root client; independent local clients remain isolated. Discovery does not create namespaces. This Runtime-wide operation requires a server and deployment route supporting namespace discovery. Custom clients that do not implement discovery fail explicitly instead of returning a partial list. -
name
-
applicationId
-
createGatewayClient
protected GatewayClient createGatewayClient(io.fluxzero.common.MessageType messageType, String topic) Description copied from class:AbstractClientSubclasses must implement this method to return aGatewayClientfor the given message type and topic.- Specified by:
createGatewayClientin classAbstractClient
-
createTrackingClient
protected TrackingClient createTrackingClient(io.fluxzero.common.MessageType messageType, String topic) Description copied from class:AbstractClientSubclasses must implement this method to return aTrackingClientfor the given message type and topic.- Specified by:
createTrackingClientin classAbstractClient
-
createEventStoreClient
Description copied from class:AbstractClientSubclasses must implement this method to return aEventStoreClient.- Specified by:
createEventStoreClientin classAbstractClient
-
createSchedulingClient
Description copied from class:AbstractClientSubclasses must implement this method to return aSchedulingClient.- Specified by:
createSchedulingClientin classAbstractClient
-
createKeyValueClient
Description copied from class:AbstractClientSubclasses must implement this method to return aKeyValueClient.- Specified by:
createKeyValueClientin classAbstractClient
-
createSearchClient
Description copied from class:AbstractClientSubclasses must implement this method to return aSearchClient.- Specified by:
createSearchClientin classAbstractClient
-
createForNamespace
- Specified by:
createForNamespacein classAbstractNamespaced<Client>
-