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 DomainEventData<?> |
extractSnapshot(org.bson.Document object)
Retrieves snapshot event data from the given Mongo
object . |
appendEvents, appendSnapshot, deleteSnapshots, eventConfiguration, findDomainEvents, findLastSnapshot, findTrackedEvents
public 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)
AbstractMongoEventStorageStrategy
events
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 AbstractMongoEventStorageStrategy
events
- the events to convert to Mongo documentsserializer
- the serializer to convert the events' payload and metadataprotected org.bson.Document createSnapshotDocument(DomainEventMessage<?> snapshot, Serializer serializer)
AbstractMongoEventStorageStrategy
serializer
to serialize event payload
and metadata.createSnapshotDocument
in class AbstractMongoEventStorageStrategy
snapshot
- the snapshot to convertserializer
- the to convert the snapshot's payload and metadataprotected Stream<? extends DomainEventData<?>> extractEvents(org.bson.Document object)
AbstractMongoEventStorageStrategy
object
.extractEvents
in class AbstractMongoEventStorageStrategy
object
- the object to convert to event dataprotected DomainEventData<?> extractSnapshot(org.bson.Document object)
AbstractMongoEventStorageStrategy
object
.extractSnapshot
in class AbstractMongoEventStorageStrategy
object
- the object to convert to snapshot datapublic void ensureIndexes(com.mongodb.client.MongoCollection<org.bson.Document> eventsCollection, com.mongodb.client.MongoCollection<org.bson.Document> snapshotsCollection)
StorageStrategy
ensureIndexes
in interface StorageStrategy
ensureIndexes
in class AbstractMongoEventStorageStrategy
eventsCollection
- The collection containing the documents representing commits and events.snapshotsCollection
- The collection containing the document representing snapshotsCopyright © 2010–2017. All rights reserved.