public class AnnotationRoutingStrategy extends AbstractRoutingStrategy
TargetAggregateIdentifier
annotation on the command message's payload. Commands are routed based on the identifier of the aggregate that they
target. This approach ensures that commands to be processed by the same aggregate are dispatched to the same node in
a DistributedCommandBus. See AnnotationCommandTargetResolver
for more details.
This class requires the returned Aggregate Identifiers to implement a proper Object.toString()
method. An
inconsistent toString() method may result in different members using different routing keys for the same identifier.AnnotationCommandTargetResolver
,
DistributedCommandBus
Constructor and Description |
---|
AnnotationRoutingStrategy()
Initializes a Routing Strategy that fails when an incoming command does not define an AggregateIdentifier 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 an AggregateIdentifier to base the routing key on. |
Modifier and Type | Method and Description |
---|---|
protected String |
doResolveRoutingKey(CommandMessage<?> command)
Resolve the Routing Key for the given
command . |
getRoutingKey
public AnnotationRoutingStrategy()
public AnnotationRoutingStrategy(UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy)
unresolvedRoutingKeyPolicy
when an incoming
command does not define an AggregateIdentifier to base the routing key on.unresolvedRoutingKeyPolicy
- The policy indication what should be done when a Command does not contain
information about the routing key to use.protected String doResolveRoutingKey(CommandMessage<?> command)
AbstractRoutingStrategy
command
.doResolveRoutingKey
in class AbstractRoutingStrategy
command
- The command to resolve the routing key fornull
if unresolved.Copyright © 2010-2013. All Rights Reserved.