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.
By default, this implementations uses a DirectExecutor to process snapshot taking
tasks. In production environments, it is recommended to use asynchronous executors instead.| Constructor and Description |
|---|
AbstractSnapshotter() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract DomainEventMessage |
createSnapshot(String typeIdentifier,
Object aggregateIdentifier,
DomainEventStream eventStream)
Creates a snapshot event for an aggregate of the given
typeIdentifier of which passed events are
available in the given eventStream. |
protected Runnable |
createSnapshotterTask(String typeIdentifier,
Object aggregateIdentifier)
Creates an instance of a task that contains the actual snapshot creation logic.
|
protected SnapshotEventStore |
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(String typeIdentifier,
Object aggregateIdentifier)
Schedules snapshot taking for an aggregate with given
typeIdentifier and
aggregateIdentifier. |
void |
setEventStore(SnapshotEventStore eventStore)
Sets the event store where the snapshotter can load domain events and store its snapshot events.
|
void |
setExecutor(Executor executor)
Sets the executor that should process actual snapshot taking.
|
void |
setTxManager(TransactionManager<?> transactionManager)
Sets the transactionManager that wraps the snapshot creation in a transaction.
|
public void scheduleSnapshot(String typeIdentifier, Object aggregateIdentifier)
SnapshottertypeIdentifier and
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 SnapshottertypeIdentifier - the type of the aggregate to take the snapshot foraggregateIdentifier - The identifier of the aggregate to take the snapshot forprotected Runnable createSnapshotterTask(String typeIdentifier, Object aggregateIdentifier)
typeIdentifier - The type of the aggregate to create a snapshot foraggregateIdentifier - The identifier of the aggregate to create a snapshot forprotected abstract DomainEventMessage createSnapshot(String typeIdentifier, Object aggregateIdentifier, DomainEventStream eventStream)
typeIdentifier 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.typeIdentifier - 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.public void setEventStore(SnapshotEventStore eventStore)
eventStore - the event store to usepublic void setExecutor(Executor executor)
executor - the executor to execute snapshotting taskspublic void setTxManager(TransactionManager<?> transactionManager)
transactionManager - the transactionManager to create transactions withprotected SnapshotEventStore getEventStore()
protected Executor getExecutor()
Copyright © 2010-2014. All Rights Reserved.