public class MongoEventStore extends Object implements SnapshotEventStore, EventStoreManagement
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 and Description |
|---|
MongoEventStore(MongoTemplate mongo)
Constructor that uses the default Serializer.
|
MongoEventStore(Serializer<? super DomainEvent> eventSerializer,
MongoTemplate mongo)
Constructor that accepts a Serializer, the MongoTemplate and a string containing the testContext.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendEvents(String type,
DomainEventStream events) |
void |
appendSnapshotEvent(String type,
DomainEvent snapshotEvent) |
void |
ensureIndexes()
Make sure an index is created on the collection that stores domain events.
|
DomainEventStream |
readEvents(String type,
AggregateIdentifier identifier) |
void |
visitEvents(EventVisitor visitor) |
public MongoEventStore(Serializer<? super DomainEvent> eventSerializer, MongoTemplate mongo)
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.@PostConstruct public void ensureIndexes()
public void appendEvents(String type, DomainEventStream events)
appendEvents in interface EventStorepublic DomainEventStream readEvents(String type, AggregateIdentifier identifier)
readEvents in interface EventStorepublic void appendSnapshotEvent(String type, DomainEvent snapshotEvent)
appendSnapshotEvent in interface SnapshotEventStorepublic void visitEvents(EventVisitor visitor)
visitEvents in interface EventStoreManagementCopyright © 2012. All Rights Reserved.