Class AbstractSnapshotter

java.lang.Object
org.axonframework.eventsourcing.AbstractSnapshotter
All Implemented Interfaces:
Snapshotter
Direct Known Subclasses:
AggregateSnapshotter

public abstract class AbstractSnapshotter extends Object implements Snapshotter
Abstract implementation of the Snapshotter that uses a task executor to creates snapshots. Actual snapshot creation logic should be provided by a subclass.
Since:
0.6
Author:
Allard Buijze
  • Constructor Details

  • Method Details

    • scheduleSnapshot

      public void scheduleSnapshot(@Nonnull Class<?> aggregateType, @Nonnull String aggregateIdentifier)
      Description copied from interface: Snapshotter
      Schedules snapshot taking for an aggregate with given aggregateIdentifier. The implementation may choose to process this call synchronously (i.e. in the caller's thread), asynchronously, or ignore the call altogether.
      Specified by:
      scheduleSnapshot in interface Snapshotter
      Parameters:
      aggregateType - the type of the aggregate to take the snapshot for
      aggregateIdentifier - The identifier of the aggregate to take the snapshot for
    • createSnapshotterTask

      protected Runnable createSnapshotterTask(Class<?> aggregateType, String aggregateIdentifier)
      Creates an instance of a task that contains the actual snapshot creation logic.
      Parameters:
      aggregateType - The type of the aggregate to create a snapshot for
      aggregateIdentifier - The identifier of the aggregate to create a snapshot for
      Returns:
      the task containing snapshot creation logic
    • createSnapshot

      protected abstract DomainEventMessage createSnapshot(Class<?> aggregateType, String aggregateIdentifier, DomainEventStream eventStream)
      Creates a snapshot event for an aggregate of which passed events are available in the given eventStream. May return null to indicate a snapshot event is not necessary or appropriate for the given event stream.
      Parameters:
      aggregateType - The aggregate's type identifier
      aggregateIdentifier - The identifier of the aggregate to create a snapshot for
      eventStream - The event stream containing the aggregate's past events
      Returns:
      the snapshot event for the given events, or null if none should be stored.
    • getEventStore

      protected EventStore getEventStore()
      Returns the event store this snapshotter uses to load domain events and store snapshot events.
      Returns:
      the event store this snapshotter uses to load domain events and store snapshot events.
    • getExecutor

      protected Executor getExecutor()
      Returns the executor that executes snapshot taking tasks.
      Returns:
      the executor that executes snapshot taking tasks.