Class AggregateDeadlineEntityIdResolverDefinition
- All Implemented Interfaces:
EntityIdResolverDefinition
EntityIdResolverDefinition resolving an entity's identifier from a command's @TargetEntityId
payload field when present, falling back to the DESCRIPTOR_BASED_ID metadata entry
AggregateDeadlineCommandTranslator writes onto every command it dispatches.
A migrated aggregate's deadline Message.payload() typically carries no usable identifier of its own, so an
entity reached through a translated deadline needs this fallback to be resolvable at all.
AggregateDeadlineEntityIdResolverConfigurationEnhancer registers this class as the application-wide
EntityIdResolverDefinition default. Every entity gets its own MetadataEntityIdResolver, built from
the idType and Configuration createIdResolver(Class, Class, EntityMetamodel, Configuration)
is given, converting the metadata value, which always is a String, with the GeneralConverter
the Configuration provides. The default, Jackson-based GeneralConverter converts a type like
Long out of the box, but not every identifier type round-trips through it. A UUID, for
example, would need a GeneralConverter able to parse an unquoted String. When the conversion fails,
the raw String value is used instead. That value still finds the entity's events, since the default event
tag uses the identifier's toString() value as well. Only an @EntityCreator that injects the
identifier then fails to match, as it expects the converted identifier type.
This identifier predicament stems from the fact that Axon Framework 4 stored the Object.toString() value of
aggregate identifiers. Hence, that's the value being returned in the metadata, not a converted format.
This definition only takes effect for an @EventSourcedEntity/@EventSourced entity, the only kind
consulting a Configuration-registered EntityIdResolverDefinition default. A migrated state-stored
aggregate (a typical Axon Framework 4 JPA aggregate) or a declaratively configured entity module never reaches this
fallback: neither consults this override point, so a deadline translated for either still fails with an
EntityIdResolutionException unless that entity's own command handler payload carries a usable identifier.
- Since:
- 5.4.0
- Author:
- Steven van Beelen
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe key under which an aggregate's identifier is expected as a fallback entity identifier, as written byAggregateDeadlineCommandTranslatoronto every command it dispatches. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<E,ID> EntityIdResolver <ID> createIdResolver(Class<E> entityType, Class<ID> idType, EntityMetamodel<E> entityMetamodel, Configuration configuration) Creates anEntityIdResolverfor the given entity type and identifier type.
-
Field Details
-
DESCRIPTOR_BASED_ID
The key under which an aggregate's identifier is expected as a fallback entity identifier, as written byAggregateDeadlineCommandTranslatoronto every command it dispatches.- See Also:
-
-
Constructor Details
-
AggregateDeadlineEntityIdResolverDefinition
public AggregateDeadlineEntityIdResolverDefinition()
-
-
Method Details
-
createIdResolver
public <E,ID> EntityIdResolver<ID> createIdResolver(Class<E> entityType, Class<ID> idType, EntityMetamodel<E> entityMetamodel, Configuration configuration) Description copied from interface:EntityIdResolverDefinitionCreates anEntityIdResolverfor the given entity type and identifier type.- Specified by:
createIdResolverin interfaceEntityIdResolverDefinition- Type Parameters:
E- the type of the entity for which the resolver is createdID- the type of the identifier for which the resolver is created- Parameters:
entityType- the type of the entity for which the resolver is createdidType- the type of the identifier for which the resolver is createdentityMetamodel- the metamodel of the entityconfiguration- the configuration of the application, providing access to the components available- Returns:
- the
EntityIdResolverfor the given entity type and identifier type
-