Class MetaDataCommandTargetResolver

java.lang.Object
org.axonframework.modelling.command.MetaDataCommandTargetResolver
All Implemented Interfaces:
CommandTargetResolver

public class MetaDataCommandTargetResolver extends Object implements CommandTargetResolver
CommandTargetResolver implementation that uses MetaData entries to extract the identifier and optionally the version of the aggregate that the command targets.

While this may require duplication of data (as the identifier is already included in the payload as well), it is a more performing alternative to a reflection based CommandTargetResolvers.

Since:
2.0
Author:
Allard Buijze
  • Constructor Details

    • MetaDataCommandTargetResolver

      public MetaDataCommandTargetResolver(String identifierKey)
      Initializes the MetaDataCommandTargetResolver to use the given identifierKey as the MetaData key to the aggregate identifier, and a null (ignored) version.

      When the given identifierKey is not present in a command's MetaData, resolveTarget(CommandMessage) will raise an IllegalArgumentException

      Parameters:
      identifierKey - The key of the metadata field containing the aggregate identifier
    • MetaDataCommandTargetResolver

      public MetaDataCommandTargetResolver(String identifierKey, String versionKey)
      Initializes the MetaDataCommandTargetResolver to use the given identifierKey as the MetaData key to the aggregate identifier, and the given versionKey as key to the (optional) version entry.

      When the given identifierKey is not present in a command's MetaData, resolveTarget(CommandMessage) will raise an IllegalArgumentException

      Parameters:
      identifierKey - The key of the metadata field containing the aggregate identifier
      versionKey - The key of the metadata field containing the expected aggregate version. A null value may be provided to ignore the version
  • Method Details