|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.mongo3.eventstore.MongoEventStore
public class MongoEventStore
Implementation of the EventStore based on a MongoDB instance or replica set. Sharding and pairing
are not explicitly supported.
This event store implementation needs a serializer as well as a MongoTemplate to interact with the mongo database.
Warning: This implementation is still in progress and may be subject to alterations. The implementation works, but has not been optimized to fully leverage MongoDB's features, yet.
| Constructor Summary | |
|---|---|
MongoEventStore(MongoTemplate mongo)
Constructor that uses the default Serializer. |
|
MongoEventStore(MongoTemplate mongoTemplate,
Serializer eventSerializer,
StorageStrategy storageStrategy)
Initialize the mongo event store with given mongoTemplate, eventSerializer and
storageStrategy. |
|
MongoEventStore(MongoTemplate mongoTemplate,
StorageStrategy storageStrategy)
Constructor that accepts a MongoTemplate and a custom StorageStrategy. |
|
MongoEventStore(Serializer eventSerializer,
MongoTemplate mongo)
Constructor that accepts a Serializer and the MongoTemplate. |
|
| Method Summary | |
|---|---|
void |
appendEvents(String type,
DomainEventStream events)
Append the events in the given stream to the event store. |
void |
appendSnapshotEvent(String type,
DomainEventMessage snapshotEvent)
Append the given snapshotEvent to the snapshot event log for the given type type. |
void |
ensureIndexes()
Make sure an index is created on the collection that stores domain events. |
MongoCriteriaBuilder |
newCriteriaBuilder()
Returns a CriteriaBuilder that allows the construction of criteria for this EventStore implementation |
DomainEventStream |
readEvents(String type,
Object identifier)
Read the events of the aggregate identified by the given type and identifier that allow the current aggregate state to be rebuilt. |
DomainEventStream |
readEvents(String type,
Object identifier,
long firstSequenceNumber)
Returns a Stream containing events for the aggregate identified by the given type and identifier, starting at the event with the given firstSequenceNumber (included). |
DomainEventStream |
readEvents(String type,
Object identifier,
long firstSequenceNumber,
long lastSequenceNumber)
Returns a Stream containing events for the aggregate identified by the given type and identifier, starting at the event with the given firstSequenceNumber (included) up to and including the
event with given lastSequenceNumber. |
void |
setUpcasterChain(UpcasterChain upcasterChain)
Sets the UpcasterChain which allow older revisions of serialized objects to be deserialized. |
void |
visitEvents(Criteria criteria,
EventVisitor visitor)
Loads all events available in the event store that match the given criteria and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage) for each event found. |
void |
visitEvents(EventVisitor visitor)
Loads all events available in the event store and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage)
for each event found. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MongoEventStore(Serializer eventSerializer,
MongoTemplate mongo)
SerializedMetaData.isSerializedMetaData(org.axonframework.serializer.SerializedObject)
eventSerializer - Your own Serializermongo - Mongo instance to obtain the database and the collections.public MongoEventStore(MongoTemplate mongo)
mongo - MongoTemplate instance to obtain the database and the collections.
public MongoEventStore(MongoTemplate mongoTemplate,
StorageStrategy storageStrategy)
mongoTemplate - The template giving access to the required collectionsstorageStrategy - The strategy for storing and retrieving events from the collections
public MongoEventStore(MongoTemplate mongoTemplate,
Serializer eventSerializer,
StorageStrategy storageStrategy)
mongoTemplate, eventSerializer and
storageStrategy.
mongoTemplate - The template giving access to the required collectionseventSerializer - The serializer to serialize events withstorageStrategy - The strategy for storing and retrieving events from the collections| Method Detail |
|---|
@PostConstruct public void ensureIndexes()
public void appendEvents(String type,
DomainEventStream events)
EventStorestream to the event store.
appendEvents in interface EventStoretype - The type descriptor of the object to storeevents - The event stream containing the events to store
public DomainEventStream readEvents(String type,
Object identifier)
EventStore
readEvents in interface EventStoretype - The type descriptor of the object to retrieveidentifier - The unique aggregate identifier of the events to load
public DomainEventStream readEvents(String type,
Object identifier,
long firstSequenceNumber)
PartialStreamSupporttype and identifier, starting at the event with the given firstSequenceNumber (included).
The returned stream will not contain any snapshot events.
readEvents in interface PartialStreamSupporttype - The type identifier of the aggregateidentifier - The identifier of the aggregatefirstSequenceNumber - The sequence number of the first event to find
public DomainEventStream readEvents(String type,
Object identifier,
long firstSequenceNumber,
long lastSequenceNumber)
PartialStreamSupporttype and identifier, starting at the event with the given firstSequenceNumber (included) up to and including the
event with given lastSequenceNumber.
If no event with given lastSequenceNumber exists, the returned stream will simply read until the end of
the aggregate's events.
The returned stream will not contain any snapshot events.
readEvents in interface PartialStreamSupporttype - The type identifier of the aggregateidentifier - The identifier of the aggregatefirstSequenceNumber - The sequence number of the first event to findlastSequenceNumber - The sequence number of the last event in the stream
public void appendSnapshotEvent(String type,
DomainEventMessage snapshotEvent)
SnapshotEventStoresnapshotEvent to the snapshot event log for the given type type. The
sequence number of the snapshotEvent must be equal to the sequence number of the last regular
domain
event that is included in the snapshot.
Implementations may choose to prune snapshots upon appending a new snapshot, in order to minimize storage space.
appendSnapshotEvent in interface SnapshotEventStoretype - The type of aggregate the event belongs tosnapshotEvent - The event summarizing one or more domain events for a specific aggregate.public void visitEvents(EventVisitor visitor)
EventStoreManagementEventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage)
for each event found. Events of a single aggregate are guaranteed to be ordered by their sequence number.
Implementations are encouraged, though not required, to supply events in the absolute chronological order.
Processing stops when the visitor throws an exception.
visitEvents in interface EventStoreManagementvisitor - The visitor the receives each loaded event
public void visitEvents(Criteria criteria,
EventVisitor visitor)
EventStoreManagementcriteria and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage) for each event found. Events of a single
aggregate are guaranteed to be ordered by their sequence number.
Implementations are encouraged, though not required, to supply events in the absolute chronological order.
Processing stops when the visitor throws an exception.
visitEvents in interface EventStoreManagementcriteria - The criteria describing the events to selectvisitor - The visitor the receives each loaded eventEventStoreManagement.newCriteriaBuilder()public MongoCriteriaBuilder newCriteriaBuilder()
EventStoreManagement
newCriteriaBuilder in interface EventStoreManagementEventStoreManagement.visitEvents(Criteria, org.axonframework.eventstore.EventVisitor)public void setUpcasterChain(UpcasterChain upcasterChain)
UpcasterAware
setUpcasterChain in interface UpcasterAwareupcasterChain - the upcaster chain providing the upcasting capabilities
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||