Interface SnapshotStore
- All Known Implementing Classes:
AxonServerSnapshotStore,InMemorySnapshotStore
Represents storage for snapshots of event-sourced entities.
A SnapshotStore is responsible for persisting and retrieving snapshots
to optimize the sourcing of entities, avoiding the need to apply all events from the beginning.
Implementations are expected to be thread-safe and fully asynchronous, returning
CompletableFuture for all operations.
- Since:
- 5.1.0
- Author:
- John Hendrikx
-
Method Summary
Modifier and TypeMethodDescriptionCompletableFuture<@Nullable Snapshot> load(QualifiedName qualifiedName, Object identifier) Loads the latest snapshot for a given name and identifier.store(QualifiedName qualifiedName, Object identifier, Snapshot snapshot) Persists a snapshot under the given name and identifier.
-
Method Details
-
store
Persists a snapshot under the given name and identifier. This replaces any previous snapshot(s) with the same name and identifier.This method is asynchronous and returns a
CompletableFuturethat completes when the snapshot has been durably stored.- Parameters:
qualifiedName- the name of the snapshot to persist, cannot benullidentifier- the identifier of the snapshot to persist, cannot benullsnapshot- the snapshot to persist, cannot benull- Returns:
- a
CompletableFuturethat completes when the snapshot has been stored - Throws:
NullPointerException- if any argument isnull
-
load
Loads the latest snapshot for a given name and identifier.The returned snapshot may have an older or newer version relative to what is expected. The caller is responsible for handling version compatibility or ignoring unusable snapshots.
This method is asynchronous and returns a
CompletableFuturethat completes with the snapshot if one exists, ornullif no snapshot is available.- Parameters:
qualifiedName- the name of the snapshot, cannot benullidentifier- the identifier of the snapshot, cannot benull- Returns:
- a
CompletableFuturecontaining the snapshot, or containingnullif no matching snapshot exists - Throws:
NullPointerException- if any argument isnull
-