org.axonframework.commandhandling.distributed
Class MetaDataRoutingStrategy

java.lang.Object
  extended by org.axonframework.commandhandling.distributed.AbstractRoutingStrategy
      extended by org.axonframework.commandhandling.distributed.MetaDataRoutingStrategy
All Implemented Interfaces:
RoutingStrategy

public class MetaDataRoutingStrategy
extends AbstractRoutingStrategy

RoutingStrategy implementation that uses the value in the MetaData of a CommandMessage assigned to a given key. The value's toString() is used to convert the MetaData value to a String.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
MetaDataRoutingStrategy(String metaDataKey)
          Initializes the MetaDataRoutingStrategy where the given metaDataKey is used to get the Meta Data value.
MetaDataRoutingStrategy(String metaDataKey, UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy)
          Initializes the MetaDataRoutingStrategy where the given metaDataKey is used to get the Meta Data value.
 
Method Summary
protected  String doResolveRoutingKey(CommandMessage<?> command)
          Resolve the Routing Key for the given command.
 
Methods inherited from class org.axonframework.commandhandling.distributed.AbstractRoutingStrategy
getRoutingKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaDataRoutingStrategy

public MetaDataRoutingStrategy(String metaDataKey)
Initializes the MetaDataRoutingStrategy where the given metaDataKey is used to get the Meta Data value. An error is raised when the MetaData key cannot be found.

Parameters:
metaDataKey - The key on which the value is retrieved from the MetaData.

MetaDataRoutingStrategy

public MetaDataRoutingStrategy(String metaDataKey,
                               UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy)
Initializes the MetaDataRoutingStrategy where the given metaDataKey is used to get the Meta Data value. The given unresolvedRoutingKeyPolicy presecribes what to do when the Meta Data properties cannot be found.

Parameters:
metaDataKey - The key on which the value is retrieved from the MetaData.
unresolvedRoutingKeyPolicy - The policy prescribing behavior when the routing key cannot be resolved
Method Detail

doResolveRoutingKey

protected String doResolveRoutingKey(CommandMessage<?> command)
Description copied from class: AbstractRoutingStrategy
Resolve the Routing Key for the given command.

Specified by:
doResolveRoutingKey in class AbstractRoutingStrategy
Parameters:
command - The command to resolve the routing key for
Returns:
the String representing the Routing Key, or null if unresolved.


Copyright © 2010-2016. All Rights Reserved.