Interface EventTypeResolver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
MessageType from the stored qualified name and version of a stored
event.
The write-side counterpart, MessageTypeResolver, derives a
MessageType from a payload class at dispatch time. This interface handles the opposite direction,
specifically for events that are reconstructed from a storage solution. Given the stored qualifiedName and
(possibly null or empty) version, it returns the MessageType to use when reading a stored
event.
The default resolver, obtained from DEFAULT, substitutes "0.0.0" for any missing
or empty stored version. This ensures that events stored by Axon Framework 4 (which allowed a null revision)
can be read by Axon Framework 5 without any schema migration. Use withDefaultVersion(String) to override the
substituted version when "0.0.0" does not suit your needs.
Implementations are permitted to rewrite the qualifiedName, but doing so is discouraged: semantic event
evolution belongs in the transformation layer, not in version normalization. This interface is intentionally narrow;
keep implementations focused on resolving a missing version.
- Since:
- 5.1.2
- Author:
- Steven van Beelen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EventTypeResolverAEventTypeResolverthat substitutes "0.0.0" for anynullor empty stored version, and passes the stored version through unchanged when present.static final StringThe version substituted fornullor empty versions by theDEFAULTevent type resolver. -
Method Summary
Modifier and TypeMethodDescriptionResolves theMessageTypefor an event read from the event store.static EventTypeResolverwithDefaultVersion(String defaultVersion) Returns aEventTypeResolverthat substitutes the givendefaultVersionfor anynullor empty stored version, and passes the stored version through unchanged when present.
-
Field Details
-
MISSING_VERSION_DEFAULT
The version substituted fornullor empty versions by theDEFAULTevent type resolver.Set to "0.0.0", deliberately distinct from
MessageType.DEFAULT_VERSION(0.0.1), so legacy AF4 events without a revision always sort as older than any explicitly versioned event.- See Also:
-
DEFAULT
AEventTypeResolverthat substitutes "0.0.0" for anynullor empty stored version, and passes the stored version through unchanged when present.
-
-
Method Details
-
withDefaultVersion
Returns aEventTypeResolverthat substitutes the givendefaultVersionfor anynullor empty stored version, and passes the stored version through unchanged when present.- Parameters:
defaultVersion- the version to use when the stored version is absent; must not benullor empty- Returns:
- a
EventTypeResolverthat substitutes the givendefaultVersionfor anynullor empty stored version, and passes the stored version through unchanged when present - Throws:
AxonConfigurationException- if the givendefaultVersionisnullor empty
-
resolve
Resolves theMessageTypefor an event read from the event store.- Parameters:
qualifiedName- the qualified name of the event as stored; nevernullversion- the version of the event as stored; may benullor empty for events written by Axon Framework 4, which allowed anullrevision- Returns:
- the
MessageTypeto use for the event; nevernull
-