public interface EventStore extends EventBus
Modifier and Type | Method and Description |
---|---|
DomainEventStream |
readEvents(String aggregateIdentifier)
Open an event stream containing all domain events belonging to the given
aggregateIdentifier . |
default DomainEventStream |
readEvents(String aggregateIdentifier,
long firstSequenceNumber)
Open an event stream containing all domain events belonging to the given
aggregateIdentifier . |
void |
storeSnapshot(DomainEventMessage<?> snapshot)
Stores the given (temporary)
snapshot event. |
openStream, publish, publish, registerDispatchInterceptor
subscribe
DomainEventStream readEvents(String aggregateIdentifier)
aggregateIdentifier
.
The returned stream is finite, ending with the last known event of the aggregate. If the event store holds no events of the given aggregate an empty stream is returned.
aggregateIdentifier
- the identifier of the aggregate whose events to fetchdefault DomainEventStream readEvents(String aggregateIdentifier, long firstSequenceNumber)
aggregateIdentifier
.
The returned stream is finite, ending with the last known event of the aggregate. If the event store holds no events of the given aggregate an empty stream is returned.
The default implementation invokes readEvents(String)
and then filters out events with a sequence number
smaller than firstSequenceNumber
.
aggregateIdentifier
- the identifier of the aggregate whose events to fetchfirstSequenceNumber
- the expected sequence number of the first event in the returned streamvoid storeSnapshot(DomainEventMessage<?> snapshot)
snapshot
event. This snapshot replaces the segment of the event stream
identified by the snapshot
's Aggregate Identifier
up
to (and including) the event with the snapshot
's sequence
number
.
These snapshots will only affect the DomainEventStream
returned by the readEvents(String)
method. They do not change the events returned by EventBus.openStream(TrackingToken)
or those received
by using SubscribableMessageSource.subscribe(java.util.function.Consumer)
.
Note that snapshots are considered a temporary replacement for Events, and are used as performance optimization. Event Store implementations may choose to ignore or delete snapshots.
snapshot
- The snapshot to replace part of the DomainEventStream.Copyright © 2010–2017. All rights reserved.