A snapshot is a persisted representation of a persistent actor’s state at a point in its event history. Recovery loads the latest snapshot and replays only later journal events, avoiding a potentially lengthy full-history reconstruction. section 9.3.3
Configure snapshotting around operational recovery needs:
- Trigger a snapshot when a significant event arrives, such as QuarterReached, or after a fixed number of processed events. section 9.3.3
- Retain only the latest snapshots needed for recovery; keeping two snapshots releases resources while preserving a fallback. section 9.3.3
- Treat snapshot failure as a logged recovery signal rather than an automatic actor stop. section 9.3.3
- Skip a known corrupted or incompatible snapshot with SnapshotSelectionCriteria.none, allowing recovery to use another path. section 9.3.3
EventSourcedBehavior[Command, Event, State](...).snapshotWhen {
case (state, QuarterReached(_), sequenceNumber) => true #1
case (state, event, sequenceNumber) => false #2
}
.withRetention(
RetentionCriteria.snapshotEvery(numberOfEvents = 100, keepNSnapshots = 2)) #3
Use snapshotWhen to trigger snapshots for selected events, then apply snapshotEvery to establish periodic retention. section 9.3.3
Persistent container recovery
A sharded SPContainer stores cargo events in a journal and takes a snapshot after every 100 events, retaining two snapshots. Its database stores journal events and snapshots in separate tables. If the actor restarts, the latest usable snapshot supplies its prior state, and only subsequent events require replay. A known bad snapshot can be excluded from recovery. section 9.4 section 9.3.3










