Class ExtractionSequencingPolicy<T,K>
java.lang.Object
org.axonframework.messaging.eventhandling.sequencing.ExtractionSequencingPolicy<T,K>
- Type Parameters:
T- The type of the supported event payloads.K- The type of the extracted property.
- All Implemented Interfaces:
SequencingPolicy
- Direct Known Subclasses:
PropertySequencingPolicy
A
SequencingPolicy implementation that extracts the sequence identifier from the event message payload based
on a given property extractor.- Since:
- 5.0.0
- Author:
- Mateusz Nowak, Nils Christian Ehmke
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of theExtractionSequencingPolicy, which extracts the sequence identifier from the event message payload of the givenpayloadClassusing the givenidentifierExtractor. -
Method Summary
Modifier and TypeMethodDescriptiongetSequenceIdentifierFor(EventMessage eventMessage, ProcessingContext context) Returns the sequence identifier for the givenevent.
-
Constructor Details
-
ExtractionSequencingPolicy
public ExtractionSequencingPolicy(@Nonnull Class<T> payloadClass, @Nonnull Function<T, K> identifierExtractor) Creates a new instance of theExtractionSequencingPolicy, which extracts the sequence identifier from the event message payload of the givenpayloadClassusing the givenidentifierExtractor.- Parameters:
payloadClass- The class of the supported event payloads.identifierExtractor- The function to extract the sequence identifier from the event payload.eventConverter- The converter to use to convert event messages if their payload is not of the expected type.
-
-
Method Details
-
getSequenceIdentifierFor
public Optional<Object> getSequenceIdentifierFor(@Nonnull EventMessage eventMessage, @Nonnull ProcessingContext context) Description copied from interface:SequencingPolicyReturns the sequence identifier for the givenevent. When two events have the same identifier (as defined by their equals method), they will be executed sequentially. AOptional#empty()value indicates that there are no sequencing requirements for the handling of this event.The
Optional#empty()should ONLY be returned when the policy cannot determine a sequence identifier for the given event. This typically happens when the policy is not applicable for the specific event type. WhenOptional#empty()is returned, it is up to the component using this policy to provide a default behavior, use another policy, or throw an exception / react in any other way - as appropriate.- Specified by:
getSequenceIdentifierForin interfaceSequencingPolicy- Parameters:
eventMessage- The event for which to get the sequencing identifier.context- The processing context in which the event is being handled. This instance of theProcessingContextdoesn't allow you to register phases actions by for exampleProcessingLifecycle.on(org.axonframework.messaging.core.unitofwork.ProcessingLifecycle.Phase, java.util.function.Function<org.axonframework.messaging.core.unitofwork.ProcessingContext, java.util.concurrent.CompletableFuture<?>>)or retrieving components byApplicationContext.component(java.lang.Class<C>).- Returns:
- A sequence identifier for the given event, or
Optional#empty()if this policy cannot determine a sequence identifier for the given event.
-