public class DocumentPerCommitStorageStrategy extends AbstractMongoEventStorageStrategy
StorageStrategy that stores one Document per commit of a batch of events.
 For instance, one command commonly gives rise to more than one event. Using this strategt all events for that single command will be grouped in a single Mongo Document.
ORDER_ASC, ORDER_DESC| Constructor and Description | 
|---|
DocumentPerCommitStorageStrategy()
Initializes a  
DocumentPerCommitStorageStrategy with default event entry and commit entry configuration. | 
DocumentPerCommitStorageStrategy(CommitEntryConfiguration commitEntryConfiguration)
Initializes a  
DocumentPerCommitStorageStrategy with default event entry and given commitEntryConfiguration. | 
DocumentPerCommitStorageStrategy(EventEntryConfiguration eventConfiguration,
                                CommitEntryConfiguration commitEntryConfiguration,
                                Duration lookBackTime)
Initializes a  
DocumentPerCommitStorageStrategy with given eventConfiguration and commitEntryConfiguration. | 
| Modifier and Type | Method and Description | 
|---|---|
protected Stream<org.bson.Document> | 
createEventDocuments(List<? extends EventMessage<?>> events,
                    Serializer serializer)
Returns a stream of Mongo documents that represent the given batch of events. 
 | 
protected org.bson.Document | 
createSnapshotDocument(DomainEventMessage<?> snapshot,
                      Serializer serializer)
Returns a Mongo document for given snapshot event. 
 | 
void | 
ensureIndexes(com.mongodb.client.MongoCollection<org.bson.Document> eventsCollection,
             com.mongodb.client.MongoCollection<org.bson.Document> snapshotsCollection)
Ensure that the correct indexes are in place. 
 | 
protected Stream<? extends DomainEventData<?>> | 
extractEvents(org.bson.Document object)
Retrieves event data from the given Mongo  
object. | 
protected Long | 
extractHighestSequenceNumber(org.bson.Document document)
Extract the highest sequence number known from the entry represented by the given  
document. | 
protected DomainEventData<?> | 
extractSnapshot(org.bson.Document object)
Retrieves snapshot event data from the given Mongo  
object. | 
appendEvents, appendSnapshot, deleteSnapshots, eventConfiguration, findDomainEvents, findLastSnapshot, findTrackedEvents, lastSequenceNumberForpublic DocumentPerCommitStorageStrategy()
DocumentPerCommitStorageStrategy with default event entry and commit entry configuration.public DocumentPerCommitStorageStrategy(CommitEntryConfiguration commitEntryConfiguration)
DocumentPerCommitStorageStrategy with default event entry and given commitEntryConfiguration.commitEntryConfiguration - object that configures the naming of commit entry propertiespublic DocumentPerCommitStorageStrategy(EventEntryConfiguration eventConfiguration, CommitEntryConfiguration commitEntryConfiguration, Duration lookBackTime)
DocumentPerCommitStorageStrategy with given eventConfiguration and commitEntryConfiguration.eventConfiguration - object that configures the naming of event entry propertiescommitEntryConfiguration - object that configures the naming of event entry propertieslookBackTime - the maximum time to look back when fetching new events while tracking.protected Stream<org.bson.Document> createEventDocuments(List<? extends EventMessage<?>> events, Serializer serializer)
AbstractMongoEventStorageStrategyevents
 represents events produced in the context of a single unit of work. Uses the given serializer to
 serialize event payload and metadata.createEventDocuments in class AbstractMongoEventStorageStrategyevents - the events to convert to Mongo documentsserializer - the serializer to convert the events' payload and metadataprotected org.bson.Document createSnapshotDocument(DomainEventMessage<?> snapshot, Serializer serializer)
AbstractMongoEventStorageStrategyserializer to serialize event payload
 and metadata.createSnapshotDocument in class AbstractMongoEventStorageStrategysnapshot - the snapshot to convertserializer - the to convert the snapshot's payload and metadataprotected Stream<? extends DomainEventData<?>> extractEvents(org.bson.Document object)
AbstractMongoEventStorageStrategyobject.extractEvents in class AbstractMongoEventStorageStrategyobject - the object to convert to event dataprotected DomainEventData<?> extractSnapshot(org.bson.Document object)
AbstractMongoEventStorageStrategyobject.extractSnapshot in class AbstractMongoEventStorageStrategyobject - the object to convert to snapshot dataprotected Long extractHighestSequenceNumber(org.bson.Document document)
AbstractMongoEventStorageStrategydocument.
 This implementation takes the sequenceNumberProperty defined in the eventConfiguration.
 Implementations that allow storage of multiple events in a single document should override this method.extractHighestSequenceNumber in class AbstractMongoEventStorageStrategydocument - The document representing the entry stored in Mongopublic void ensureIndexes(com.mongodb.client.MongoCollection<org.bson.Document> eventsCollection,
                          com.mongodb.client.MongoCollection<org.bson.Document> snapshotsCollection)
StorageStrategyensureIndexes in interface StorageStrategyensureIndexes in class AbstractMongoEventStorageStrategyeventsCollection - The collection containing the documents representing commits and events.snapshotsCollection - The collection containing the document representing snapshotsCopyright © 2010–2018. All rights reserved.