|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.mongo3.eventstore.DocumentPerEventStorageStrategy
public class DocumentPerEventStorageStrategy
Implementation of the StorageStrategy that stores each event as a separate document. This makes it easier to query the event store for specific events, but does not allow for atomic storage of a single commit.
The structure is as follows:SerializedMetaData.isSerializedMetaData(org.axonframework.serializer.SerializedObject)
Constructor Summary | |
---|---|
DocumentPerEventStorageStrategy()
|
Method Summary | |
---|---|
List<org.bson.Document> |
createDocuments(String type,
Serializer eventSerializer,
List<DomainEventMessage> messages)
Generates the DBObject instances that need to be stored for a commit. |
void |
ensureIndexes(com.mongodb.client.MongoCollection eventsCollection,
com.mongodb.client.MongoCollection snapshotsCollection)
Ensure that the correct indexes are in place. |
List<DomainEventMessage> |
extractEventMessages(org.bson.Document entry,
Object aggregateIdentifier,
Serializer serializer,
UpcasterChain upcasterChain,
boolean skipUnknownTypes)
Extracts the individual Event Messages from the given entry . |
com.mongodb.client.MongoCursor<org.bson.Document> |
findEvents(com.mongodb.client.MongoCollection<org.bson.Document> collection,
MongoCriteria criteria)
Find all events that match the given criteria in the given collection |
com.mongodb.client.MongoCursor<org.bson.Document> |
findEvents(com.mongodb.client.MongoCollection<org.bson.Document> collection,
String aggregateType,
String aggregateIdentifier,
long firstSequenceNumber)
Provides a cursor for access to all events for an aggregate with given aggregateType and
aggregateIdentifier , with a sequence number equal or higher than the given
firstSequenceNumber . |
com.mongodb.client.MongoCursor<org.bson.Document> |
findLastSnapshot(com.mongodb.client.MongoCollection<org.bson.Document> collection,
String aggregateType,
String aggregateIdentifier)
Finds the entry containing the last snapshot event for an aggregate with given aggregateType and
aggregateIdentifier in the given collection . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DocumentPerEventStorageStrategy()
Method Detail |
---|
public List<org.bson.Document> createDocuments(String type, Serializer eventSerializer, List<DomainEventMessage> messages)
StorageStrategy
createDocuments
in interface StorageStrategy
type
- The aggregate's type identifiereventSerializer
- The serializer to serialize events withmessages
- The messages contained in this commit
public com.mongodb.client.MongoCursor<org.bson.Document> findEvents(com.mongodb.client.MongoCollection<org.bson.Document> collection, String aggregateType, String aggregateIdentifier, long firstSequenceNumber)
StorageStrategy
aggregateType
and
aggregateIdentifier
, with a sequence number equal or higher than the given
firstSequenceNumber
. The returned documents should be ordered chronologically (typically by using
the sequence number).
Each DBObject document returned as result of this cursor will be passed to StorageStrategy.extractEventMessages(org.bson.Document, java.lang.Object, org.axonframework.serializer.Serializer, org.axonframework.upcasting.UpcasterChain, boolean)
in order to retrieve individual DomainEventMessages.
findEvents
in interface StorageStrategy
collection
- The collection to search for eventsaggregateType
- The type identifier of the aggregate to queryaggregateIdentifier
- The identifier of the aggregate to queryfirstSequenceNumber
- The sequence number of the first event to return
public List<DomainEventMessage> extractEventMessages(org.bson.Document entry, Object aggregateIdentifier, Serializer serializer, UpcasterChain upcasterChain, boolean skipUnknownTypes)
StorageStrategy
entry
. The aggregateIdentifier
is passed to allow messages to contain the actual object, instead of its serialized form. The
serializer
and upcasterChain
should be used to deserialize and upcast messages before
returning them.
extractEventMessages
in interface StorageStrategy
entry
- The entry containing information of a stored commitaggregateIdentifier
- The aggregate identifier used to query eventsserializer
- The serializer to deserialize events withupcasterChain
- The upcaster chain to upcast stored events withskipUnknownTypes
- Whether unknown event types should be skipped
public void ensureIndexes(com.mongodb.client.MongoCollection eventsCollection, com.mongodb.client.MongoCollection snapshotsCollection)
StorageStrategy
ensureIndexes
in interface StorageStrategy
eventsCollection
- The collection containing the documents representing commits and events.snapshotsCollection
- The collection containing the document representing snapshotspublic com.mongodb.client.MongoCursor<org.bson.Document> findEvents(com.mongodb.client.MongoCollection<org.bson.Document> collection, MongoCriteria criteria)
StorageStrategy
criteria
in the given collection
findEvents
in interface StorageStrategy
collection
- The collection to search for eventscriteria
- The criteria to match against the events
public com.mongodb.client.MongoCursor<org.bson.Document> findLastSnapshot(com.mongodb.client.MongoCollection<org.bson.Document> collection, String aggregateType, String aggregateIdentifier)
StorageStrategy
aggregateType
and
aggregateIdentifier
in the given collection
. For each result returned by the Cursor,
an invocation to StorageStrategy.extractEventMessages(org.bson.Document, java.lang.Object, org.axonframework.serializer.Serializer, org.axonframework.upcasting.UpcasterChain, boolean)
will be used to extract
the actual DomainEventMessages.
findLastSnapshot
in interface StorageStrategy
collection
- The collection to find the last snapshot event inaggregateType
- The type identifier of the aggregate to find a snapshot foraggregateIdentifier
- The identifier of the aggregate to find a snapshot for
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |