Class PropertySequencingPolicy<T,K>

java.lang.Object
org.axonframework.eventhandling.async.PropertySequencingPolicy<T,K>
Type Parameters:
T - The type of the supported event payloads.
K - The type of the extracted property.
All Implemented Interfaces:
SequencingPolicy<EventMessage>

public class PropertySequencingPolicy<T,K> extends Object implements SequencingPolicy<EventMessage>
A SequencingPolicy implementation that extracts the sequence identifier from the event message payload based on a given property or property extractor. If the event message payload is not of a supported type, a fallback sequencing policy is used. By default the fallback sequencing policy raises an exception.
Since:
4.5.2
Author:
Nils Christian Ehmke
  • Constructor Details

  • Method Details

    • getSequenceIdentifierFor

      public Object getSequenceIdentifierFor(@Nonnull EventMessage eventMessage)
      Description copied from interface: SequencingPolicy
      Returns the sequence identifier for the given event. When two events have the same identifier (as defined by their equals method), they will be executed sequentially. A null value indicates that there are no sequencing requirements for the handling of this event.
      Specified by:
      getSequenceIdentifierFor in interface SequencingPolicy<T>
      Parameters:
      eventMessage - the event for which to get the sequencing identifier
      Returns:
      a sequence identifier for the given event
    • builder

      public static <T, K> PropertySequencingPolicy.Builder<T,K> builder(Class<T> payloadClass, Class<K> propertyClass)
      Instantiate a Builder to be able to create a PropertySequencingPolicy.

      Upon initialization of this builder, the following fields are defaulted:

      • The fallbackSequencingPolicy defaults to an exception raising sequencing policy.
      The following fields of this builder are hard requirements and as such should be provided:
      • The payloadClass which defines the supported type of event message payload.
      • The propertyExtractor which is applied to the payload and extract the sequence identifier.
      • The fallbackSequencingPolicy which defines the behaviour in case of an unsupported event payload.
      Type Parameters:
      T - the type of the supported event payloads
      K - the type of the extracted property
      Parameters:
      payloadClass - the class of the supported event payloads
      propertyClass - the class of the extracted property
      Returns:
      a Builder to be able to create a PropertySequencingPolicy