load

open override fun <S : Any> load(aggregateId: AggregateId, metadata: StateAggregateMetadata<S> = aggregateId.requiredAggregateType<Any>() .aggregateMetadata<Any, S>().state, tailVersion: Int = Int.MAX_VALUE): Mono<StateAggregate<S>>

Loads a state aggregate by its ID up to a specified version.

This method reconstructs the aggregate state by:

  • Loading from snapshot if tailVersion is Int.MAX_VALUE and a snapshot exists

  • Creating a new aggregate instance otherwise

  • Applying events from the event store up to the specified tailVersion

Return

A Mono emitting the reconstructed StateAggregate.

Parameters

aggregateId

The unique identifier of the aggregate to load.

metadata

Metadata describing the aggregate structure and behavior.

tailVersion

The maximum version to load events up to. Use Int.MAX_VALUE for latest version.

Type Parameters

S

The type of the aggregate state.

Throws

if aggregateId or metadata is invalid.

if event sourcing fails due to event store errors.

Samples


open override fun <S : Any> load(aggregateId: AggregateId, metadata: StateAggregateMetadata<S> = aggregateId.requiredAggregateType<Any>() .aggregateMetadata<Any, S>().state, tailEventTime: Long): Mono<StateAggregate<S>>

Loads a state aggregate by its ID up to a specified event time.

This method reconstructs the aggregate state by:

  • Creating a new aggregate instance

  • Applying events from the event store that occurred before or at the specified tailEventTime

Return

A Mono emitting the reconstructed StateAggregate.

Parameters

aggregateId

The unique identifier of the aggregate to load.

metadata

Metadata describing the aggregate structure and behavior.

tailEventTime

The maximum event timestamp (in milliseconds since epoch) to load events up to.

Type Parameters

S

The type of the aggregate state.

Throws

if aggregateId or metadata is invalid.

if event sourcing fails due to event store errors.

Samples