All Superinterfaces:
HasLocalHandlers
All Known Implementing Classes:
DefaultEventStore

public interface EventStore extends HasLocalHandlers
High-level abstraction for accessing and storing domain events in an event-sourced system.

This interface allows writing and reading event streams associated with aggregate instances. It is responsible for storing events produced by aggregates and retrieving event histories to rebuild aggregate state during rehydration.

Usage Note: While this interface is public, it is rarely used directly. Applications typically use higher-level abstractions such as:

See Also:
  • Method Details

    • storeEvents

      default CompletableFuture<Void> storeEvents(Object aggregateId, Object... events)
      Stores one or more events for a given aggregate using the default strategy EventPublicationStrategy.STORE_AND_PUBLISH.
      Parameters:
      aggregateId - The ID of the aggregate.
      events - One or more events to store.
      Returns:
      A future that completes when the events have been successfully stored.
    • storeEvents

      default CompletableFuture<Void> storeEvents(Object aggregateId, List<?> events)
      Stores a list of events for a given aggregate using the default strategy EventPublicationStrategy.STORE_AND_PUBLISH.
      Parameters:
      aggregateId - The ID of the aggregate.
      events - The list of events to store.
      Returns:
      A future that completes when the events have been successfully stored.
    • storeEvents

      CompletableFuture<Void> storeEvents(Object aggregateId, List<?> events, EventPublicationStrategy strategy)
      Stores a list of events for the given aggregate using a specified publication strategy.
      Parameters:
      aggregateId - The ID of the aggregate.
      events - The events to store.
      strategy - Whether to publish the events in addition to storing them.
      Returns:
      A future that completes once the operation is acknowledged.
    • getEvents

      default AggregateEventStream<DeserializingMessage> getEvents(Object aggregateId)
      Retrieves the full event stream for an aggregate starting from the beginning.
      Parameters:
      aggregateId - The ID of the aggregate.
      Returns:
      A stream of deserialized messages representing the event history of the aggregate.
    • getEvents

      default AggregateEventStream<DeserializingMessage> getEvents(Object aggregateId, long lastSequenceNumber)
      Retrieves the event stream for an aggregate starting after the specified sequence number.
      Parameters:
      aggregateId - The ID of the aggregate.
      lastSequenceNumber - The last known sequence number to resume from.
      Returns:
      A stream of deserialized messages representing the event history of the aggregate.
    • getEvents

      default AggregateEventStream<DeserializingMessage> getEvents(Object aggregateId, long lastSequenceNumber, int maxSize)
      Retrieves the event stream for an aggregate starting after a given sequence number, with a maximum limit.
      Parameters:
      aggregateId - The ID of the aggregate.
      lastSequenceNumber - The last known sequence number to resume from.
      maxSize - The maximum number of events to return. A negative value means no limit.
      Returns:
      A stream of deserialized messages representing the event history of the aggregate.
    • getEvents

      AggregateEventStream<DeserializingMessage> getEvents(Object aggregateId, long lastSequenceNumber, int maxSize, boolean ignoreUnknownType)
      Retrieves the event stream for an aggregate with full control over behavior.
      Parameters:
      aggregateId - The ID of the aggregate.
      lastSequenceNumber - The last known sequence number to resume from.
      maxSize - The maximum number of events to return.
      ignoreUnknownType - Whether to ignore unknown payload types when deserializing events.
      Returns:
      A stream of deserialized messages representing the event history of the aggregate.