public abstract class AbstractSnapshotter extends Object implements Snapshotter
Snapshotter
that uses a task executor to
creates snapshots. Actual snapshot creation logic should be provided by a subclass.Modifier | Constructor and Description |
---|---|
protected |
AbstractSnapshotter(EventStore eventStore)
Initializes the Snapshotter to append snapshots in the given
eventStore . |
protected |
AbstractSnapshotter(EventStore eventStore,
Executor executor,
TransactionManager transactionManager)
Initializes the Snapshotter to append snapshots in the given
eventStore . |
protected |
AbstractSnapshotter(EventStore eventStore,
TransactionManager transactionManager)
Initializes the Snapshotter to append snapshots in the given
eventStore . |
Modifier and Type | Method and Description |
---|---|
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 . |
protected Runnable |
createSnapshotterTask(Class<?> aggregateType,
String aggregateIdentifier)
Creates an instance of a task that contains the actual snapshot creation logic.
|
protected EventStore |
getEventStore()
Returns the event store this snapshotter uses to load domain events and store snapshot events.
|
protected Executor |
getExecutor()
Returns the executor that executes snapshot taking tasks.
|
void |
scheduleSnapshot(Class<?> aggregateType,
String aggregateIdentifier)
Schedules snapshot taking for an aggregate with given
aggregateIdentifier . |
protected AbstractSnapshotter(EventStore eventStore)
eventStore
. This snapshotter will create the
snapshots in the process that triggers them, and save them into the Event Store without any transaction.eventStore
- the EventStore instance to store snapshots inprotected AbstractSnapshotter(EventStore eventStore, TransactionManager transactionManager)
eventStore
. This snapshotter will create the
snapshots in the process that triggers them, and save them into the Event Store in a transaction managed by the
given transactionManager
.eventStore
- the EventStore instance to store snapshots intransactionManager
- The transaction manager to create the surrounding transaction withprotected AbstractSnapshotter(EventStore eventStore, Executor executor, TransactionManager transactionManager)
eventStore
. This snapshotter will create the
snapshots in the process provided by the given executor
, and save them into the Event Store in a
transaction managed by the given transactionManager
.eventStore
- The EventStore instance to store snapshots inexecutor
- The executor that handles the actual snapshot creation processtransactionManager
- The transaction manager to create the surrounding transaction withpublic void scheduleSnapshot(Class<?> aggregateType, String aggregateIdentifier)
Snapshotter
aggregateIdentifier
. The implementation may
choose to process this call synchronously (i.e. in the caller's thread), asynchronously, or ignore the call
altogether.scheduleSnapshot
in interface Snapshotter
aggregateType
- the type of the aggregate to take the snapshot foraggregateIdentifier
- The identifier of the aggregate to take the snapshot forprotected Runnable createSnapshotterTask(Class<?> aggregateType, String aggregateIdentifier)
aggregateType
- The type of the aggregate to create a snapshot foraggregateIdentifier
- The identifier of the aggregate to create a snapshot forprotected abstract DomainEventMessage createSnapshot(Class<?> aggregateType, String aggregateIdentifier, DomainEventStream eventStream)
eventStream
.
May return null
to indicate a snapshot event is not necessary or appropriate for the given event stream.aggregateType
- The aggregate's type identifieraggregateIdentifier
- The identifier of the aggregate to create a snapshot foreventStream
- The event stream containing the aggregate's past eventsnull
if none should be stored.protected EventStore getEventStore()
protected Executor getExecutor()
Copyright © 2010–2018. All rights reserved.