public class EventCountSnapshotTriggerDefinition extends Object implements SnapshotTriggerDefinition
This number can exceed in two distinct scenarios:
If the definable
threshold is met in situation one, the snapshot will be triggered regardless of the outcome
of command handling. Thus also if command handling returns exceptionally. If the
threshold is only reached
once the aggregate has been fully initialized, than the snapshot will only be triggered if handling resolves
|Constructor and Description|
Initialized the SnapshotTriggerDefinition to threshold snapshots using the given
|Modifier and Type||Method and Description|
Prepares a new trigger for an aggregate with the given
Reconfigure the necessary infrastructure components in the given
public EventCountSnapshotTriggerDefinition(Snapshotter snapshotter, int threshold)
thresholdevents have been applied to an Aggregate instance
snapshotter- the snapshotter to notify when a snapshot needs to be taken
threshold- the number of events that will threshold the creation of a snapshot event
public SnapshotTrigger prepareTrigger(Class<?> aggregateType)
aggregateType. The trigger will be notified of each event applied on the aggregate, as well as the moment at which the aggregate state is fully initialized based on its historic events.
It is highly recommended that the instances returned by this method are
resources that the trigger needs that are not serializable, can be reattached by implementing the
SnapshotTriggerDefinition.reconfigure(Class, SnapshotTrigger) method. This method is invoked when a SnapshotTrigger has been
public SnapshotTrigger reconfigure(Class<?> aggregateType, SnapshotTrigger trigger)
trigger instance, which may have been lost in the (de)serialization process.
Implementations returning a Serializable SnapshotTrigger (which is recommended), should implement this method if not all fields could be initialized base don serialized data.
aggregateType- The type of aggregate for which this trigger was created
trigger- The trigger instance formerly created using
Copyright © 2010–2020. All rights reserved.