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>
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 Summary
ConstructorsConstructorDescriptionRoutingKeyCommandTargetResolver(AnnotatedEntityMetamodel<E> metamodel, String entityRoutingProperty, String messageRoutingProperty) Constructs aRoutingKeyCommandTargetResolverthat matches the routing key of the givenentityagainst the routing key of a command message. -
Method Summary
Modifier and TypeMethodDescriptiongetTargetChildEntity(List<E> childEntities, CommandMessage message, ProcessingContext context) Returns the target child entity for the given command message.
-
Constructor Details
-
RoutingKeyCommandTargetResolver
public RoutingKeyCommandTargetResolver(@Nonnull AnnotatedEntityMetamodel<E> metamodel, @Nonnull String entityRoutingProperty, @Nonnull String messageRoutingProperty) Constructs aRoutingKeyCommandTargetResolverthat matches the routing key of the givenentityagainst the routing key of a command message. The routing key of the entity is determined by theentityRoutingPropertyand the routing key of the command message is determined by themessageRoutingProperty.- Parameters:
metamodel- TheAnnotatedEntityMetamodelof 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:CommandTargetResolverReturns 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
nullif no child entity is found that can handle the command. In that case, theCommandTargetResolvershould not throw an exception, but rather allow the command to be handled by another child entity.- Specified by:
getTargetChildEntityin interfaceCommandTargetResolver<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
nullif no suitable entity is found.
-