Class AggregateDeadlineEntityIdResolverDefinition

java.lang.Object
org.axonframework.deadline.AggregateDeadlineEntityIdResolverDefinition
All Implemented Interfaces:
EntityIdResolverDefinition

public class AggregateDeadlineEntityIdResolverDefinition extends Object implements EntityIdResolverDefinition
An 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 Details

  • 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: EntityIdResolverDefinition
      Creates an EntityIdResolver for the given entity type and identifier type.
      Specified by:
      createIdResolver in interface EntityIdResolverDefinition
      Type Parameters:
      E - the type of the entity for which the resolver is created
      ID - the type of the identifier for which the resolver is created
      Parameters:
      entityType - the type of the entity for which the resolver is created
      idType - the type of the identifier for which the resolver is created
      entityMetamodel - the metamodel of the entity
      configuration - the configuration of the application, providing access to the components available
      Returns:
      the EntityIdResolver for the given entity type and identifier type