Class AggregateBasedAxonServerEventStorageEngine
- All Implemented Interfaces:
DescribableComponent,EventStorageEngine
- Since:
- 5.0.0
- Author:
- Allard Buijze
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.eventsourcing.eventstore.EventStorageEngine
EventStorageEngine.AppendTransaction<R> -
Constructor Summary
ConstructorsConstructorDescriptionAggregateBasedAxonServerEventStorageEngine(io.axoniq.axonserver.connector.AxonServerConnection connection, EventConverter converter) Initialize theLegacyAxonServerEventStorageEnginewith givenconnectionto Axon Server and givenpayloadConverterto convert payloads of appended messages (to bytes). -
Method Summary
Modifier and TypeMethodDescriptionappendEvents(AppendCondition condition, ProcessingContext context, List<TaggedEventMessage<?>> events) voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.eventsourcing.eventstore.EventStorageEngine
appendEvents
-
Constructor Details
-
AggregateBasedAxonServerEventStorageEngine
public AggregateBasedAxonServerEventStorageEngine(@Nonnull io.axoniq.axonserver.connector.AxonServerConnection connection, @Nonnull EventConverter converter) Initialize theLegacyAxonServerEventStorageEnginewith givenconnectionto Axon Server and givenpayloadConverterto convert payloads of appended messages (to bytes).- Parameters:
connection- The backing connection to Axon Serverconverter- The converter to use to serialize payloads to bytes
-
-
Method Details
-
appendEvents
public CompletableFuture<EventStorageEngine.AppendTransaction<?>> appendEvents(@Nonnull AppendCondition condition, @Nullable ProcessingContext context, @Nonnull List<TaggedEventMessage<?>> events) Description copied from interface:EventStorageEngineAppends 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.- Specified by:
appendEventsin interfaceEventStorageEngine- 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
Description copied from interface:EventStorageEngineCreates 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.
- Specified by:
sourcein interfaceEventStorageEngine- Parameters:
condition- TheSourcingConditiondictating thestreamofeventsto source.- Returns:
- A finite
MessageStreamofeventsmatching the givencondition.
-
stream
Description copied from interface:EventStorageEngineCreates an infiniteMessageStreamofeventsmatching the givencondition.The
conditionmay dictate theStreamingCondition.position()to start streaming from, as well as definefilter criteriafor the returnedMessageStream.- Specified by:
streamin interfaceEventStorageEngine- Parameters:
condition- TheStreamingConditiondictating theStreamingCondition.position()to start streaming from, as well as thefilter criteriaused for the returnedMessageStream.- Returns:
- An infinite
MessageStreamofeventsmatching the givencondition.
-
firstToken
Description copied from interface:EventStorageEngineCreates aTrackingTokenthat is at the first position of an event stream.In other words, a token that tracks events from the beginning of time.
- Specified by:
firstTokenin interfaceEventStorageEngine- Returns:
- A
CompletableFutureof aTrackingTokenat the first position of an event stream.
-
latestToken
Description copied from interface:EventStorageEngineCreates aTrackingTokenthat is at the latest position of an event stream.In other words, a token that tracks all new events from this point forward.
- Specified by:
latestTokenin interfaceEventStorageEngine- Returns:
- A
CompletableFutureof aTrackingTokenat the latest position of an event stream.
-
tokenAt
Description copied from interface:EventStorageEngineCreates aTrackingTokenthat tracks alleventsafter the givenat.If there is an event exactly at the given
at, it will be tracked too.- Specified by:
tokenAtin interfaceEventStorageEngine- 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
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-