Class TracingEventStorageEngine
- All Implemented Interfaces:
DescribableComponent,EventStorageEngine
EventStorageEngine. It traces the complete logical append operation, beginning
when EventStorageEngine.appendEvents(AppendCondition, ProcessingContext, List) is invoked and ending when
the returned EventStorageEngine.AppendTransaction reaches a terminal outcome through
EventStorageEngine.AppendTransaction.afterCommit(Object), EventStorageEngine.AppendTransaction.rollback(), or a failure.
When a ProcessingContext is supplied, the span additionally ends with the context as a leak backstop, so an
abandoned transaction cannot leave it open. Without a context there is no lifecycle to attach that backstop to: the
span then ends only through the transaction's terminal operations, and a caller that abandons such a transaction
without committing or rolling back leaves the span unfinished.
Read and token operations are delegated unchanged. The decorator is installed by the event-sourcing tracing configuration and is not intended for direct application use.
- Since:
- 5.3.0
- Author:
- Mateusz Nowak
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.eventsourcing.eventstore.EventStorageEngine
EventStorageEngine.AppendTransaction<R> -
Constructor Summary
ConstructorsConstructorDescriptionTracingEventStorageEngine(EventStorageEngine delegate, SpanFactory spanFactory) Initializes a tracing decorator for the givendelegate. -
Method Summary
Modifier and TypeMethodDescriptionappendEvents(AppendCondition condition, @Nullable 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, @Nullable ProcessingContext context) Creates a finiteMessageStreamofeventsmatching the givencondition, carrying along the activeProcessingContext.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, source
-
Constructor Details
-
TracingEventStorageEngine
Initializes a tracing decorator for the givendelegate.- Parameters:
delegate- the event storage engine to delegate tospanFactory- the factory producing the append span
-
-
Method Details
-
appendEvents
public CompletableFuture<EventStorageEngine.AppendTransaction<?>> appendEvents(AppendCondition condition, @Nullable ProcessingContext context, 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
public MessageStream<EventMessage> source(SourcingCondition condition, @Nullable ProcessingContext context) Description copied from interface:EventStorageEngineCreates a finiteMessageStreamofeventsmatching the givencondition, carrying along the activeProcessingContext.Behaves identically to
EventStorageEngine.source(SourcingCondition); thecontextis passed to decorators (for example snapshot-loading and tracing decorators) that need to correlate the sourcing operation with the surrounding unit of work.- Specified by:
sourcein interfaceEventStorageEngine- Parameters:
condition- theSourcingConditiondictating thestreamofeventsto sourcecontext- theProcessingContextactive while sourcing; may benull- 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.
-