public class AnnotationRoutingStrategy extends AbstractRoutingStrategy
RoutingKey (meta-)annotation on the command
message's payload. Commands are routed based on an identifier annotated with the RoutingKey. This approach ensures
that commands with the same identifier, thus dealt with by the same target, are dispatched to the same node in
a DistributedCommandBus.
An example would be the org.axonframework.commandhandling.TargetAggregateIdentifier, which is annotated with
RoutingKey. See org.axonframework.commandhandling.AnnotationCommandTargetResolver for more details on this
approach.
Object.toString() method. An inconsistent
toString() method may result in different members using different routing keys for the same identifier.org.axonframework.commandhandling.TargetAggregateIdentifier,
org.axonframework.commandhandling.AnnotationCommandTargetResolver,
DistributedCommandBus| Constructor and Description |
|---|
AnnotationRoutingStrategy()
Initializes a Routing Strategy that fails when an incoming command does not define a field as the
RoutingKey to base the routing on. |
AnnotationRoutingStrategy(Class<? extends Annotation> annotationType)
Initializes a Routing Strategy that uses the given annotation to resolve the targeted identifier.
|
AnnotationRoutingStrategy(Class<? extends Annotation> annotationType,
UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy)
Initializes a Routing Strategy that uses the given annotation to resolve the targeted identifier and the given
unresolvedRoutingKeyPolicy when an incoming command does not define an Identifier to base the routing key
on. |
AnnotationRoutingStrategy(UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy)
Initializes a Routing Strategy that uses the given
unresolvedRoutingKeyPolicy when an incoming
command does not define a RoutingKey annotated field to base the routing on. |
| Modifier and Type | Method and Description |
|---|---|
protected String |
doResolveRoutingKey(CommandMessage<?> command)
Resolve the Routing Key for the given
command. |
getRoutingKeypublic AnnotationRoutingStrategy()
RoutingKey to base the routing on.public AnnotationRoutingStrategy(Class<? extends Annotation> annotationType)
annotationType - the type of annotation marking the field or method providing the identifier of the targeted
modelpublic AnnotationRoutingStrategy(UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy)
unresolvedRoutingKeyPolicy when an incoming
command does not define a RoutingKey annotated field to base the routing on.unresolvedRoutingKeyPolicy - a UnresolvedRoutingKeyPolicy indicating what should be done when a
Command does not contain information about the routing key to usepublic AnnotationRoutingStrategy(Class<? extends Annotation> annotationType, UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy)
unresolvedRoutingKeyPolicy when an incoming command does not define an Identifier to base the routing key
on.annotationType - the type of annotation marking the field or method providing the identifier of
the targeted modelunresolvedRoutingKeyPolicy - a UnresolvedRoutingKeyPolicy indicating what should be done when a
Command does not contain information about the routing key to useprotected String doResolveRoutingKey(CommandMessage<?> command)
AbstractRoutingStrategycommand.doResolveRoutingKey in class AbstractRoutingStrategycommand - The command to resolve the routing key fornull if unresolved.Copyright © 2010–2018. All rights reserved.