Class AggregateBasedEventStorageEngineUtils
java.lang.Object
org.axonframework.eventsourcing.eventstore.AggregateBasedEventStorageEngineUtils
Utility class for handling various operations related to the Aggregate-based Event Storage Engine.
- Since:
- 5.0.0
- Author:
- Mateusz Nowak, Allard Buijze
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertValidTags(List<TaggedEventMessage<?>> events) Validates the tags associated with a list of event messages.static StringresolveAggregateIdentifier(Set<Tag> tags) Resolves the aggregate identifier from the provided set of tags.static StringresolveAggregateType(Set<Tag> tags) Resolves the aggregate type from the provided set of tags.static ExceptiontranslateConflictException(ConsistencyMarker consistencyMarker, Exception exception, Predicate<Throwable> isConflictException) Translates the givenExceptioninto anAppendEventsTransactionRejectedExceptionif it is identified as a conflict through the givenisConflictExceptionpredicate.static ThrowabletranslateConflictException(ConsistencyMarker consistencyMarker, Throwable e, Predicate<Throwable> isConflictException) Translates the givenThrowableinto anAppendEventsTransactionRejectedExceptionif it is identified as a conflict through the givenisConflictExceptionpredicate.
-
Method Details
-
assertValidTags
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
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
nullif the set is empty. - Throws:
IllegalArgumentException- if the set contains more than one tag.
-
resolveAggregateType
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
nullif 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 givenExceptioninto anAppendEventsTransactionRejectedExceptionif it is identified as a conflict through the givenisConflictExceptionpredicate. 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 givenThrowableinto anAppendEventsTransactionRejectedExceptionif it is identified as a conflict through the givenisConflictExceptionpredicate. 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.
-