Interface SnapshotTrigger

All Known Implementing Classes:
AbstractSnapshotTrigger

public interface SnapshotTrigger
Interface describing a mechanism that keeps track of an Aggregate's activity in order to trigger a snapshot. The trigger is notified of events handled by the aggregate and the time at which initialization of "current state" has been completed.

It is up to the Trigger implementation to decide when, how and where a snapshot is triggered.

SnapshotTrigger implementations do not need to be thread-safe.

It is highly recommended to make trigger instances Serializable. The trigger instance is attached to the aggregate instance which it monitors, causing it to be cached and potentially serialized alongside it.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Invoked when an event is handled by an aggregate.
    void
    Invoked when the initialization of the aggregate based on passed events is completed.
  • Method Details

    • eventHandled

      void eventHandled(@Nonnull EventMessage<?> msg)
      Invoked when an event is handled by an aggregate. While these messages usually extend DomainEventMessage, this is not guaranteed. The given message can either be a historic Message from the Event Store, or one that has been just applied by the aggregate.
      Parameters:
      msg - The message handled by the aggregate
    • initializationFinished

      void initializationFinished()
      Invoked when the initialization of the aggregate based on passed events is completed. Any subsequent invocation of eventHandled(EventMessage) involves an event being applied on "current state".