public class FileSystemEventStore extends Object implements EventStore, SnapshotEventStore, UpcasterAware
EventStore that serializes objects (by default using
XStream) and
writes them to files to disk. Each aggregate is represented by a single file.
Use EventFileResolver to specify the directory where event files should be stored and written to.
Note that the resource supplied must point to a folder and should contain a trailing slash. See org.springframework.core.io.FileSystemResource#FileSystemResource(String).| Constructor and Description |
|---|
FileSystemEventStore(EventFileResolver eventFileResolver)
Basic initialization of the event store.
|
FileSystemEventStore(Serializer serializer,
EventFileResolver eventFileResolver)
Initialize the FileSystemEventStore using the given
serializer. |
| Modifier and Type | Method and Description |
|---|---|
void |
appendEvents(String type,
DomainEventStream eventsToStore)
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. |
DomainEventStream |
readEvents(String type,
Object aggregateIdentifier)
Read the events of the aggregate identified by the given type and identifier that allow the current aggregate
state to be rebuilt.
|
void |
setUpcasterChain(UpcasterChain upcasterChain)
Sets the UpcasterChain which allow older revisions of serialized objects to be deserialized.
|
public FileSystemEventStore(EventFileResolver eventFileResolver)
XStreamSerializereventFileResolver - The EventFileResolver providing access to event filespublic FileSystemEventStore(Serializer serializer, EventFileResolver eventFileResolver)
serializer. The serializer must be capable of
serializing the payload and meta data of Event Messages.
Note: the SerializedType of Message Meta Data is not stored. Upon retrieval, it is set to the default value
(name = "org.axonframework.domain.MetaData", revision = null). See SerializedMetaData.isSerializedMetaData(org.axonframework.serializer.SerializedObject)serializer - The serializer capable of serializing (at least) DomainEventseventFileResolver - The EventFileResolver providing access to event filespublic void appendEvents(String type, DomainEventStream eventsToStore)
stream to the event store.
This implementation writes events to an event log on the file system. It uses a directory per type of aggregate,
containing 1 file per aggregate.appendEvents in interface EventStoretype - The type descriptor of the object to storeeventsToStore - The event stream containing the events to storepublic DomainEventStream readEvents(String type, Object aggregateIdentifier)
EventStorereadEvents in interface EventStoretype - The type descriptor of the object to retrieveaggregateIdentifier - The unique aggregate identifier of the events to loadpublic void appendSnapshotEvent(String type, DomainEventMessage snapshotEvent) throws EventStoreException
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 SnapshotEventStoretype - The type of aggregate the event belongs tosnapshotEvent - The event summarizing one or more domain events for a specific aggregate.EventStoreException - when an error occurs while reading or writing to the event logs.public void setUpcasterChain(UpcasterChain upcasterChain)
UpcasterAwaresetUpcasterChain in interface UpcasterAwareupcasterChain - the upcaster chain providing the upcasting capabilitiesCopyright © 2010-2014. All Rights Reserved.