|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.eventstore.mongo.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 collectionspublic 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 collectionsMethod Detail |
---|
@PostConstruct public void ensureIndexes()
public void appendEvents(String type, DomainEventStream events)
EventStore
stream
to the event store.
appendEvents
in interface EventStore
type
- The type descriptor of the object to storeevents
- The event stream containing the events to storepublic DomainEventStream readEvents(String type, Object identifier)
EventStore
readEvents
in interface EventStore
type
- 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)
PartialStreamSupport
type
and identifier
, starting at the event with the given firstSequenceNumber
(included).
The returned stream will not contain any snapshot events.
readEvents
in interface PartialStreamSupport
type
- 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)
PartialStreamSupport
type
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 PartialStreamSupport
type
- 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)
SnapshotEventStore
snapshotEvent
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 SnapshotEventStore
type
- 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)
EventStoreManagement
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 EventStoreManagement
visitor
- The visitor the receives each loaded eventpublic void visitEvents(Criteria criteria, EventVisitor visitor)
EventStoreManagement
criteria
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 EventStoreManagement
criteria
- The criteria describing the events to selectvisitor
- The visitor the receives each loaded eventEventStoreManagement.newCriteriaBuilder()
public MongoCriteriaBuilder newCriteriaBuilder()
EventStoreManagement
newCriteriaBuilder
in interface EventStoreManagement
EventStoreManagement.visitEvents(Criteria, org.axonframework.eventstore.EventVisitor)
public void setUpcasterChain(UpcasterChain upcasterChain)
UpcasterAware
setUpcasterChain
in interface UpcasterAware
upcasterChain
- the upcaster chain providing the upcasting capabilities
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |