Interface EventStoreTransaction
- All Known Implementing Classes:
DefaultEventStoreTransaction
public interface EventStoreTransaction
Interface describing the actions that can be taken on a transaction to source a model from the
EventStore
based on the resulting MessageStream.
Note that this transaction includes operations for source(SourcingCondition) the model as well as
appending events.
- Since:
- 5.0.0
- Author:
- Allard Buijze, Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptionvoidappendEvent(EventMessage eventMessage) Appends aneventMessageto be appended to anEventStorein this transaction with the givencondition.Returns the position in the event store of the lastappendedevent by this transaction.voidonAppend(Consumer<EventMessage> callback) Registers acallbackto invoke when an event isappendedto this transaction.MessageStream<? extends EventMessage> source(SourcingCondition condition) Sources aMessageStreamof typeEventMessagebased on the givenconditionthat can be used to rehydrate a model.
-
Method Details
-
source
Sources aMessageStreamof typeEventMessagebased on the givenconditionthat can be used to rehydrate a model.Note that the usage of
criteriadoes not make sense for sourcing, as it is not recommended to source the entire event store.Any
EventStoreTransactionusing theEventStorageEngine.source(SourcingCondition)is expected tofiltertheTerminalEventMessagewith theConsistencyMarker.- Parameters:
condition- TheSourcingConditionused to retrieve theMessageStreamcontaining the sequence of events that can rehydrate a model.- Returns:
- The
MessageStreamof typeEventMessagecontaining to the event sequence complying to the givencondition.
-
appendEvent
Appends aneventMessageto be appended to anEventStorein this transaction with the givencondition.Use the
EventCriteria.havingAnyTag()when there are no consistency boundaries to validate during appending.- Parameters:
eventMessage- TheEventMessageto append.
-
onAppend
Registers acallbackto invoke when an event isappendedto this transaction.Each
callbackregistration adds a new callback that is invoked on theappendEvent(EventMessage, AppendCondition)operation.- Parameters:
callback- AConsumerto invoke when an event is appended in this transaction.
-
appendPosition
ConsistencyMarker appendPosition()Returns the position in the event store of the lastappendedevent by this transaction.Will return
ConsistencyMarker.ORIGINif nothing has been appended yet.- Returns:
- The position in the event store of the last
appendedevent by this transaction.
-