@Snapshot
You can declare a maintained snapshot with @Snapshot on both the blocking and reactor stacks. A factory method returning a SnapshotView is registered as a managed subscription that keeps one snapshot per stream up to date, exactly like @Projection, including catch-up from history and durable resume. A factory returning a DcbSnapshotView instead maintains one snapshot per DCB boundary. Resolve the store with store = SomeStore.class or storeName, or leave both unset for a zero-config MongoDB store (SpringMongoSnapshotStore on the blocking stack, ReactiveSpringMongoSnapshotStore on the reactor stack). everyNEvents throttles how often the maintained snapshot is written, and mode selects ASYNC (catch-up then live) or SYNCHRONOUS (updated on the write path for read-your-writes).
@Snapshot(id = "account-state", everyNEvents = 100)public SnapshotView<AccountState, AccountEvent> accountSnapshot() { return SnapshotView.<AccountState, AccountEvent>builder(AccountState.EMPTY) .schemaVersion(1) .on(MoneyDeposited.class, (state, e) -> state.add(e.amount())) .on(MoneyWithdrawn.class, (state, e) -> state.subtract(e.amount())) .build();}@Snapshot(id = "account-state", everyNEvents = 100)fun accountSnapshot(): SnapshotView<AccountState, AccountEvent> = snapshotView(AccountState.EMPTY) { schemaVersion(1) on<MoneyDeposited> { state, e -> state.add(e.amount) } on<MoneyWithdrawn> { state, e -> state.subtract(e.amount) }}The subscription that keeps the snapshot up to date is filtered to the event types the SnapshotView registers handlers for, derived as described in Deriving the Event Filter. If the SnapshotView registers a handler for a type listed as refused in that section, Spring Boot startup fails.
