Interface SourcingStrategy

All Known Implementing Classes:
SourcingStrategy.Absolute, SourcingStrategy.Snapshot

public sealed interface SourcingStrategy permits SourcingStrategy.Absolute, SourcingStrategy.Snapshot
Defines how a sourcing operation should construct the message stream when reading events from an event store.

There are two supported forms:

Merging

Sourcing strategies can be merged to produce a single effective strategy used for sourcing. The merge rules are deterministic:
  • Merging two SourcingStrategy.Absolute strategies results in the minimum of both positions
  • Merging an Absolute with a Snapshot always results in the Snapshot
  • Merging two Snapshot instances is not supported and results in an exception

Snapshot semantics

The SourcingStrategy.Snapshot strategy provides initial state, replacing the initial part of the event stream if initial state was available. It is identified by:
  • A QualifiedName, defining the snapshot type
  • An identifier (typically an aggregate or entity id)
  • An optional maximum Position, limiting which snapshots are acceptable
When a snapshot is used, the event store may return:
  • The latest snapshot matching the identity whose position is at or before the specified maximum position
  • All subsequent events from the snapshot’s position onward
If no snapshot is available, the event store falls back to sourcing events only.
Since:
5.1.1
Author:
John Hendrikx
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Absolute start position in the event stream.
    static final record 
    Snapshot-based sourcing strategy.
  • Method Summary

    Modifier and Type
    Method
    Description
    Merges this sourcing strategy with another sourcing strategy to produce a single effective strategy for event sourcing.