Interface SnapshotStore

All Known Implementing Classes:
AxonServerSnapshotStore, InMemorySnapshotStore

@Internal public interface SnapshotStore
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 Details

    • store

      CompletableFuture<Void> store(QualifiedName qualifiedName, Object identifier, Snapshot snapshot)
      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 CompletableFuture that completes when the snapshot has been durably stored.

      Parameters:
      qualifiedName - the name of the snapshot to persist, cannot be null
      identifier - the identifier of the snapshot to persist, cannot be null
      snapshot - the snapshot to persist, cannot be null
      Returns:
      a CompletableFuture that completes when the snapshot has been stored
      Throws:
      NullPointerException - if any argument is null
    • load

      CompletableFuture<@Nullable Snapshot> load(QualifiedName qualifiedName, Object identifier)
      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 CompletableFuture that completes with the snapshot if one exists, or null if no snapshot is available.

      Parameters:
      qualifiedName - the name of the snapshot, cannot be null
      identifier - the identifier of the snapshot, cannot be null
      Returns:
      a CompletableFuture containing the snapshot, or containing null if no matching snapshot exists
      Throws:
      NullPointerException - if any argument is null