Class AggregateBasedEventStorageEngineUtils

java.lang.Object
org.axonframework.eventsourcing.eventstore.AggregateBasedEventStorageEngineUtils

public final class AggregateBasedEventStorageEngineUtils extends Object
Utility class for handling various operations related to the Aggregate-based Event Storage Engine.
Since:
5.0.0
Author:
Mateusz Nowak, Allard Buijze
  • Method Details

    • assertValidTags

      public static void assertValidTags(List<TaggedEventMessage<?>> events)
      Validates the tags associated with a list of event messages. Ensures that no event has more than one tag, as the Event Storage engine in Aggregate mode only supports a single tag per event.
      Parameters:
      events - The list of tagged event messages to validate.
      Throws:
      TooManyTagsOnEventMessageException - if any event has more than one tag.
    • resolveAggregateIdentifier

      @Nullable public static String resolveAggregateIdentifier(Set<Tag> tags)
      Resolves the aggregate identifier from the provided set of tags. The set must contain exactly one tag, and its value will be returned as the aggregate identifier.
      Parameters:
      tags - The set of tags to resolve the aggregate identifier from.
      Returns:
      The aggregate identifier, or null if the set is empty.
      Throws:
      IllegalArgumentException - if the set contains more than one tag.
    • resolveAggregateType

      @Nullable public static String resolveAggregateType(Set<Tag> tags)
      Resolves the aggregate type from the provided set of tags. The set must contain exactly one tag, and its key will be returned as the aggregate type.
      Parameters:
      tags - The set of tags to resolve the aggregate type from.
      Returns:
      The aggregate type, or null if the set is empty.
      Throws:
      IllegalArgumentException - if the set contains more than one tag.
    • translateConflictException

      public static Exception translateConflictException(ConsistencyMarker consistencyMarker, Exception exception, Predicate<Throwable> isConflictException)
      Translates the given Exception into an AppendEventsTransactionRejectedException if it is identified as a conflict through the given isConflictException predicate. If the exception is not a conflict, it recursively checks the cause of the exception.
      Parameters:
      consistencyMarker - The consistency marker used to identify conflicting events.
      isConflictException - A predicate used to check if the exception is a conflict.
      e - The exception to translate.
      Returns:
      The translated exception.
    • translateConflictException

      public static Throwable translateConflictException(ConsistencyMarker consistencyMarker, Throwable e, Predicate<Throwable> isConflictException)
      Translates the given Throwable into an AppendEventsTransactionRejectedException if it is identified as a conflict through the given isConflictException predicate. If the exception is not a conflict, it recursively checks the cause of the exception.
      Parameters:
      consistencyMarker - The consistency marker used to identify conflicting events.
      e - The exception to translate.
      isConflictException - A predicate used to check if the exception is a conflict.
      Returns:
      The translated exception.