Class RoutingKeyCommandTargetResolver<E>

java.lang.Object
org.axonframework.modelling.entity.annotation.RoutingKeyCommandTargetResolver<E>
Type Parameters:
E - The type of the child entity this resolver matches against.
All Implemented Interfaces:
CommandTargetResolver<E>

public class RoutingKeyCommandTargetResolver<E> extends Object implements CommandTargetResolver<E>
EventTargetMatcher implementation that matches based on the routing key. If the routing key of the message matches the routing key of the child entity, the child entity is considered a match.

Note: This class was known as {code org.axonframework.modelling.command.ForwardMatchingInstances} before version 5.0.0.

Since:
5.0.0
Author:
Mitchell Herrijgers
  • Constructor Details

    • RoutingKeyCommandTargetResolver

      public RoutingKeyCommandTargetResolver(@Nonnull AnnotatedEntityMetamodel<E> metamodel, @Nonnull String entityRoutingProperty, @Nonnull String messageRoutingProperty)
      Constructs a RoutingKeyCommandTargetResolver that matches the routing key of the given entity against the routing key of a command message. The routing key of the entity is determined by the entityRoutingProperty and the routing key of the command message is determined by the messageRoutingProperty.
      Parameters:
      metamodel - The AnnotatedEntityMetamodel of the entity to match against.
      entityRoutingProperty - The routing key property of the entity, which is used to match against the command.
      messageRoutingProperty - The routing key property of the command, which is used to match against the entity.
  • Method Details

    • getTargetChildEntity

      public E getTargetChildEntity(@Nonnull List<E> childEntities, @Nonnull CommandMessage message, @Nonnull ProcessingContext context)
      Description copied from interface: CommandTargetResolver
      Returns the target child entity for the given command message. This method is called when multiple child entities are present and the command needs to be routed to the correct one.

      Can return null if no child entity is found that can handle the command. In that case, the CommandTargetResolver should not throw an exception, but rather allow the command to be handled by another child entity.

      Specified by:
      getTargetChildEntity in interface CommandTargetResolver<E>
      Parameters:
      childEntities - The list of candidate child entities that can handle the command.
      message - The command message to resolve the target child entity for.
      context - The processing context in which the command is being processed.
      Returns:
      The target child entity that should handle the command, or null if no suitable entity is found.