Interface SnapshotStore
- All Superinterfaces:
DescribableComponent
- All Known Implementing Classes:
AxonServerSnapshotStore,InMemorySnapshotStore,MultiTenantSnapshotStore,PostgresqlEventStorageEngine,TracingSnapshotStore
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, @Nullable ProcessingContext context) Loads the latest snapshot for a given name and identifier.store(QualifiedName qualifiedName, Object identifier, Snapshot snapshot, @Nullable ProcessingContext context) Persists a snapshot under the given name and identifier.Methods inherited from interface org.axonframework.common.infra.DescribableComponent
describeTo
-
Method Details
-
store
CompletableFuture<Void> store(QualifiedName qualifiedName, Object identifier, Snapshot snapshot, @Nullable ProcessingContext context) 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 benullcontext- theProcessingContextactive while storing, used by decorators (e.g. tracing) to correlate the operation with the surrounding unit of work; may benull- Returns:
- a
CompletableFuturethat completes when the snapshot has been stored - Throws:
NullPointerException- if any non-nullable argument isnull
-
load
CompletableFuture<@Nullable Snapshot> load(QualifiedName qualifiedName, Object identifier, @Nullable ProcessingContext context) 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 benullcontext- theProcessingContextactive while loading, used by decorators (e.g. tracing) to correlate the operation with the surrounding unit of work; may benull- Returns:
- a
CompletableFuturecontaining the snapshot, or containingnullif no matching snapshot exists - Throws:
NullPointerException- if any non-nullable argument isnull
-