Class WebSocketEventStoreClient
java.lang.Object
io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
io.fluxcapacitor.javaclient.persisting.eventsourcing.client.WebSocketEventStoreClient
- All Implemented Interfaces:
EventStoreClient
,AutoCloseable
WebSocket-based implementation of the
EventStoreClient
, enabling interaction with the Flux Platform's event
store via a persistent WebSocket connection.
This implementation supports:
- Storing events for event-sourced aggregates
- Efficient, paginated retrieval of aggregate event streams
- Deleting aggregate event streams
- Maintaining aggregate/entity relationships
The fetchBatchSize
setting controls how many events are fetched per paginated request when loading
an aggregate's event history. This ensures efficient memory usage while still supporting large aggregates.
End users rarely interact with this client directly. Instead, they typically use higher-level abstractions
such as EventStore
or
AggregateRepository
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
AbstractWebsocketClient.PingRegistration, AbstractWebsocketClient.WebSocketRequest
-
Field Summary
Fields inherited from class io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
defaultObjectMapper, defaultWebSocketContainer
-
Constructor Summary
ConstructorsConstructorDescriptionWebSocketEventStoreClient
(String endPointUrl, WebSocketClient client) Creates a newWebSocketEventStoreClient
with a default batch size of 8192.WebSocketEventStoreClient
(URI endPointUri, int fetchBatchSize, WebSocketClient client) Creates a newWebSocketEventStoreClient
with a specified batch size.WebSocketEventStoreClient
(URI endPointUri, int fetchBatchSize, WebSocketClient client, boolean sendMetrics) Constructs the WebSocket client with full customization. -
Method Summary
Modifier and TypeMethodDescriptiondeleteEvents
(String aggregateId, Guarantee guarantee) Sends a delete command for the event stream of the specified aggregate.getAggregateIds
(GetAggregateIds request) Retrieves a map of aggregate IDs associated with a given entity, using aGetAggregateIds
request.Retrieves events for a specific aggregate starting after a given sequence number, optionally limiting the result size.getRelationships
(GetRelationships request) Retrieves all relationships for a given entity, using aGetRelationships
request.repairRelationships
(RepairRelationships request) Sends a request to repair relationships for a specific entity.storeEvents
(String aggregateId, List<SerializedMessage> events, boolean storeOnly, Guarantee guarantee) Stores events for a specific aggregate, with control over store-only mode and delivery guarantee.updateRelationships
(UpdateRelationships request) Sends a request to update the relationships of an entity or aggregate.Methods inherited from class io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
abort, close, close, handleResult, metricsMetadata, onClose, onError, onMessage, onOpen, onPong, retryOutstandingRequests, schedulePing, send, sendAndWait, sendCommand, sendPing, toString, tryPublishMetrics
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.javaclient.persisting.eventsourcing.client.EventStoreClient
close, deleteEvents, getAggregatesFor, getEvents, getEvents, getRelationships, storeEvents
-
Constructor Details
-
WebSocketEventStoreClient
Creates a newWebSocketEventStoreClient
with a default batch size of 8192.- Parameters:
endPointUrl
- The URL to the Flux Platform event sourcing endpoint.client
- The WebSocket client instance.
-
WebSocketEventStoreClient
Creates a newWebSocketEventStoreClient
with a specified batch size.- Parameters:
endPointUri
- The URI to the event store endpoint.fetchBatchSize
- Maximum number of events to retrieve per page.client
- The WebSocket client.
-
WebSocketEventStoreClient
public WebSocketEventStoreClient(URI endPointUri, int fetchBatchSize, WebSocketClient client, boolean sendMetrics) Constructs the WebSocket client with full customization.- Parameters:
endPointUri
- URI of the event sourcing endpoint.fetchBatchSize
- The size of event batches fetched from the server.client
- The WebSocket client.sendMetrics
- Whether to send metrics to the Flux Platform.
-
-
Method Details
-
storeEvents
public CompletableFuture<Void> storeEvents(String aggregateId, List<SerializedMessage> events, boolean storeOnly, Guarantee guarantee) Stores events for a specific aggregate, with control over store-only mode and delivery guarantee.- Specified by:
storeEvents
in interfaceEventStoreClient
- Parameters:
aggregateId
- The aggregate ID.events
- Events to store.storeOnly
- Iftrue
, events will not be published.guarantee
- The guarantee level for this operation.- Returns:
- A future representing completion of the store operation.
-
getEvents
public AggregateEventStream<SerializedMessage> getEvents(String aggregateId, long lastSequenceNumber, int maxSize) Retrieves events for a specific aggregate starting after a given sequence number, optionally limiting the result size.- Specified by:
getEvents
in interfaceEventStoreClient
- Parameters:
aggregateId
- The aggregate ID.lastSequenceNumber
- Sequence number to resume after.maxSize
- Maximum number of events to return (or -1 for unlimited).- Returns:
- A stream of serialized events.
-
updateRelationships
Sends a request to update the relationships of an entity or aggregate.- Specified by:
updateRelationships
in interfaceEventStoreClient
- Parameters:
request
- The update request.- Returns:
- A future that completes when the operation is acknowledged.
-
repairRelationships
Sends a request to repair relationships for a specific entity.- Specified by:
repairRelationships
in interfaceEventStoreClient
- Parameters:
request
- The repair request.- Returns:
- A future that completes when the repair is done.
-
getAggregateIds
Retrieves a map of aggregate IDs associated with a given entity, using aGetAggregateIds
request.- Specified by:
getAggregateIds
in interfaceEventStoreClient
- Parameters:
request
- The request containing filtering options.- Returns:
- A map of aggregate IDs referencing the target entity.
-
getRelationships
Retrieves all relationships for a given entity, using aGetRelationships
request.- Specified by:
getRelationships
in interfaceEventStoreClient
- Parameters:
request
- The request containing filter parameters.- Returns:
- A list of matching relationships.
-
deleteEvents
Sends a delete command for the event stream of the specified aggregate.- Specified by:
deleteEvents
in interfaceEventStoreClient
- Parameters:
aggregateId
- The aggregate ID.guarantee
- The guarantee to apply.- Returns:
- A future that completes when deletion is acknowledged.
-