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 and Type | Class and Description |
---|---|
static class |
AbstractSnapshotter.Builder
Abstract Builder class to instantiate
AbstractSnapshotter implementations. |
Modifier | Constructor and Description |
---|---|
protected |
AbstractSnapshotter(AbstractSnapshotter.Builder builder)
Instantiate a
AbstractSnapshotter based on the fields contained in the AbstractSnapshotter.Builder . |
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(AbstractSnapshotter.Builder builder)
AbstractSnapshotter
based on the fields contained in the AbstractSnapshotter.Builder
.
Will assert that the EventStore
is not null
, and will throw an AxonConfigurationException
if it is null
.
builder
- the AbstractSnapshotter.Builder
used to instantiate a AbstractSnapshotter
instancepublic void scheduleSnapshot(@Nonnull Class<?> aggregateType, @Nonnull 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–2024. All rights reserved.