Class SequenceCachingEventHandlingComponent
java.lang.Object
org.axonframework.messaging.eventhandling.DelegatingEventHandlingComponent
org.axonframework.messaging.eventhandling.processing.streaming.segmenting.SequenceCachingEventHandlingComponent
- All Implemented Interfaces:
DescribableComponent,MessageHandler,EventHandler,EventHandlingComponent
@Internal
public class SequenceCachingEventHandlingComponent
extends DelegatingEventHandlingComponent
Decorator for
EventHandlingComponent. This implementation acts as a performance optimization layer by caching
the results of sequence identifier calculations. Since sequence identifier computation can be expensive, this caching
component reduces redundant calculations for events which sequence identifier has already been calculated within the
same ProcessingContext.
The cache is stored as a resource in the ProcessingContext, ensuring that the cache is scoped to the current
processing unit of work. This means the cache is automatically cleaned up when the processing context is completed.
Example usage within framework configuration:
EventHandlingComponent component = // ... create base component
EventHandlingComponent cachingComponent = new SequenceCachingEventHandlingComponent(component);
- Since:
- 5.0.0
- Author:
- Mateusz Nowak
-
Field Summary
Fields inherited from class org.axonframework.messaging.eventhandling.DelegatingEventHandlingComponent
delegate -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the component with givendelegateto receive calls. -
Method Summary
Modifier and TypeMethodDescriptionsequenceIdentifierFor(EventMessage event, ProcessingContext context) Returns the sequence identifier for the givenevent.Methods inherited from class org.axonframework.messaging.eventhandling.DelegatingEventHandlingComponent
describeTo, handle, supportedEvents, supports
-
Constructor Details
-
SequenceCachingEventHandlingComponent
Constructs the component with givendelegateto receive calls.- Parameters:
delegate- TheEventHandlingComponentinstance to delegate calls to.
-
-
Method Details
-
sequenceIdentifierFor
@Nonnull public Object sequenceIdentifierFor(@Nonnull EventMessage event, @Nonnull ProcessingContext context) Description copied from interface:EventHandlingComponentReturns the sequence identifier for the givenevent. When two events have the same sequence identifier (as defined by their equals method), they will be executed sequentially. Important: AllEventHandlersfor the sameQualifiedNamewithin a singleEventHandlingComponentmust return the same sequence identifier for a given event. Mixing different sequence identifiers within the scope of a singleEventHandlingComponentis not supported and may lead to undefined behavior.- Specified by:
sequenceIdentifierForin interfaceEventHandlingComponent- Overrides:
sequenceIdentifierForin classDelegatingEventHandlingComponent- Parameters:
event- The event for which to get the sequencing identifier.context- The processing context in which the event is being handled.- Returns:
- A sequence identifier for the given event.
-