Interface EventStorageEngine
- All Superinterfaces:
DescribableComponent
- All Known Implementing Classes:
AggregateBasedAxonServerEventStorageEngine,AggregateBasedJpaEventStorageEngine,AxonServerEventStorageEngine,InMemoryEventStorageEngine
StorageEngineBackedEventStore.
Provides a mechanism to
invalid reference
#appendEvents(AppendCondition, TaggedEventMessage[])events from an underlying storage mechanism.
Retrieval can be done either through sourcing or
streaming. The former generates a finite stream intended to event source
(for example) a model. The latter provides an infinite stream.
- Since:
- 3.0
- Author:
- Allard Buijze, Milan Savić, Rene de Waele, Steven van Beelen
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInterface representing the transaction of an appendEvents invocation. -
Method Summary
Modifier and TypeMethodDescriptionappendEvents(AppendCondition condition, ProcessingContext context, List<TaggedEventMessage<?>> events) appendEvents(AppendCondition condition, ProcessingContext context, TaggedEventMessage<?>... events) Append one or moreeventsto the underlying storage solution.Creates aTrackingTokenthat is at the first position of an event stream.Creates aTrackingTokenthat is at the latest position of an event stream.source(SourcingCondition condition) stream(StreamingCondition condition) Methods inherited from interface org.axonframework.common.infra.DescribableComponent
describeTo
-
Method Details
-
appendEvents
default CompletableFuture<EventStorageEngine.AppendTransaction<?>> appendEvents(@Nonnull AppendCondition condition, @Nullable ProcessingContext context, @Nonnull TaggedEventMessage<?>... events) Append one or moreeventsto the underlying storage solution.Events will be appended in the order that they are offered in, validating the given
conditionbefore being stored. Note that all events should have a unique event identifier.Tagspaired with theeventswill be stored as well.By default, this method creates a
Listof the offered events and then invokes.invalid reference
#appendEvents(AppendCondition, List)Called during the
PREPARE_COMMITphase.- Parameters:
condition- The condition describing the transactional requirements for the append transactioncontext- The currentProcessingContext, if any.events- One or moreeventsto append to the underlying storage solution.- Returns:
- A
transactioninstance that can be committed or rolled back.
-
appendEvents
CompletableFuture<EventStorageEngine.AppendTransaction<?>> appendEvents(@Nonnull AppendCondition condition, @Nullable ProcessingContext context, @Nonnull List<TaggedEventMessage<?>> events) Appends aListofeventsto the underlying storage solution.Events will be appended in the order that they are offered in, validating the given
conditionbefore being stored. Note that all events should have a unique event identifier.Tagspaired with theeventswill be stored as well.Implementations may be able to detect conflicts during the append stage. In such case, the returned completable future will complete exceptionally, indicating such conflict. Other implementations may delay such checks until the
EventStorageEngine.AppendTransaction.commit()is called.Called during the
PREPARE_COMMITphase.- Parameters:
condition- The condition describing the transactional requirements for the append transactioncontext- The currentProcessingContext, if any.events- TheListofeventsto append to the underlying storage solution.- Returns:
- A
transactioninstance that can be committed or rolled back.
-
source
Creates a finiteMessageStreamofeventsmatching the givencondition.The final entry of the stream always contains a
ConsistencyMarkerin theMessageStream.Entry's resources, paired with aTerminalEventMessage. ThisConsistencyMarkershould be used to construct theAppendConditionwhen.invalid reference
appending eventsThe
conditiondictates the sequence to load based on theEventsCondition.criteria(). Additionally, an optionalSourcingCondition.start()andposition may be provided.invalid reference
SourcingCondition#end()The returned stream is finite, i.e. it should not block to wait for further events if the end of the event stream of the aggregate is reached.
- Parameters:
condition- TheSourcingConditiondictating thestreamofeventsto source.- Returns:
- A finite
MessageStreamofeventsmatching the givencondition.
-
stream
Creates an infiniteMessageStreamofeventsmatching the givencondition.The
conditionmay dictate theStreamingCondition.position()to start streaming from, as well as definefilter criteriafor the returnedMessageStream.- Parameters:
condition- TheStreamingConditiondictating theStreamingCondition.position()to start streaming from, as well as thefilter criteriaused for the returnedMessageStream.- Returns:
- An infinite
MessageStreamofeventsmatching the givencondition.
-
firstToken
CompletableFuture<TrackingToken> firstToken()Creates aTrackingTokenthat is at the first position of an event stream.In other words, a token that tracks events from the beginning of time.
- Returns:
- A
CompletableFutureof aTrackingTokenat the first position of an event stream.
-
latestToken
CompletableFuture<TrackingToken> latestToken()Creates aTrackingTokenthat is at the latest position of an event stream.In other words, a token that tracks all new events from this point forward.
- Returns:
- A
CompletableFutureof aTrackingTokenat the latest position of an event stream.
-
tokenAt
Creates aTrackingTokenthat tracks alleventsafter the givenat.If there is an event exactly at the given
at, it will be tracked too.- Parameters:
at- TheInstantdetermining how theTrackingTokenshould be created. A tracking token should point to very first event before thisInstant.- Returns:
- A
CompletableFutureof aTrackingTokenat the givenat, if there aren't events matching this criterianullis returned
-