Annotation Interface EntityMember
Messages are filtered based on the eventTargetMatcher() and commandTargetResolver(), which both
default to a matcher based on the routingKey(). The default routing key matcher and resolver will match a
property on the child entity and the message that matches the routingKey() attribute.
The routingKey() property is required whenever there are several child entities of the same type
within a class. Hence, it is required when a collection of child entities is used. However, it also applies when
several singular child entity fields of the same type exist within an entity. For purely singular child
entities (not backed by an Iterable nor reoccurring within the class), this can be omitted.
Note that this annotation existed as org.axonframework.modelling.command.AggregateMember before version
5.0.0. Besides the change in name to align better with the entities instead of aggregates, the version introduced the
commandTargetResolver(), which before was not configurable.
- Since:
- 3.0.0
- Author:
- Allard Buijze, Mitchell Herrijgers
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends CommandTargetResolverDefinition> TheCommandTargetResolverDefinitionis used to determine to which of the child entities aCommandMessageshould be forwarded.Class<? extends EventTargetMatcherDefinition> TheEventTargetMatcheris used to determine which entity should be evolved by theEventMessage.The routing key to use for matching messages with this child entity.
-
Element Details
-
routingKey
String routingKeyThe routing key to use for matching messages with this child entity.This attribute is required whenever there are several child entities of the same type. For example, when a collection of child entities is used.
Defaults to an empty string, which means no matching will take place.
- Returns:
- the routing key to use for matching messages to this child entity
- Default:
""
-
eventTargetMatcher
Class<? extends EventTargetMatcherDefinition> eventTargetMatcherTheEventTargetMatcheris used to determine which entity should be evolved by theEventMessage.The forwarding mode can match 0, 1, or multiple child entities, and as such functions like a predicate or filter.
Defaults to using the
RoutingKeyEventTargetMatcher, which matches messages based on theroutingKey(). Users can choose to create their own definition, with their own forwarding mode, that has specific routing logic.- Returns:
- the class defining the
EventTargetMatcherfor this child entity
- Default:
org.axonframework.modelling.entity.annotation.RoutingKeyEventTargetMatcherDefinition.class
-
commandTargetResolver
Class<? extends CommandTargetResolverDefinition> commandTargetResolverTheCommandTargetResolverDefinitionis used to determine to which of the child entities aCommandMessageshould be forwarded.The result should always be a single child entity, or no child entity at all, as a command can only be handled by a single entity.
The result can also be
nullto indicate that no child entity should handle the command. This allows users to declare multiple fields with the same child entity type, but with different routing key properties, with different routing logic for commands.Defaults to using the
RoutingKeyCommandTargetResolverDefinition, which matches messages based on theroutingKey(). Users can choose to create their own definition, with their own forwarding mode, that has specific routing logic.- Returns:
- the class defining
CommandTargetResolverfor this child entity
- Default:
org.axonframework.modelling.entity.annotation.RoutingKeyCommandTargetResolverDefinition.class
-