Class MetaDataRoutingStrategy
java.lang.Object
org.axonframework.commandhandling.distributed.AbstractRoutingStrategy
org.axonframework.commandhandling.distributed.MetaDataRoutingStrategy
- All Implemented Interfaces:
RoutingStrategy
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aAnnotationRoutingStrategy. -
Constructor Summary
ConstructorsModifierConstructorDescriptionMetaDataRoutingStrategy(String metaDataKey) Deprecated.MetaDataRoutingStrategy(String metaDataKey, UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy) Deprecated.in favor of thebuilder()protectedInstantiate aMetaDataRoutingStrategybased on the fields contained in the givebuilder. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Instantiate a Builder to be able to create aMetaDataRoutingStrategy.protected StringdoResolveRoutingKey(CommandMessage<?> command) Resolve the Routing Key for the givencommand.Methods inherited from class org.axonframework.commandhandling.distributed.AbstractRoutingStrategy
getRoutingKey
-
Constructor Details
-
MetaDataRoutingStrategy
Instantiate aMetaDataRoutingStrategybased on the fields contained in the givebuilder.Will assert that the
metaDataKeyis not an emptyStringornulland will throw anAxonConfigurationExceptionif this is the case.- Parameters:
builder- theMetaDataRoutingStrategy.Builderused to instantiate aMetaDataRoutingStrategyinstance
-
MetaDataRoutingStrategy
Deprecated.in favor of thebuilder()Initializes the MetaDataRoutingStrategy where the givenmetaDataKeyis 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
@Deprecated public MetaDataRoutingStrategy(String metaDataKey, UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy) Deprecated.in favor of thebuilder()Initializes the MetaDataRoutingStrategy where the givenmetaDataKeyis used to get the Meta Data value. The givenunresolvedRoutingKeyPolicyprescribes what to do when the Meta Data properties cannot be found.- Parameters:
metaDataKey- the key on which the value is retrieved from the MetaDataunresolvedRoutingKeyPolicy- the policy prescribing behavior when the routing key cannot be resolved
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aMetaDataRoutingStrategy.The
fallbackRoutingStrategytoUnresolvedRoutingKeyPolicy.RANDOM_KEY. ThemetaDataKeyis a hard requirements and as such should be provided.- Returns:
- a Builder to be able to create a
MetaDataRoutingStrategy
-
doResolveRoutingKey
Description copied from class:AbstractRoutingStrategyResolve the Routing Key for the givencommand.- Specified by:
doResolveRoutingKeyin classAbstractRoutingStrategy- Parameters:
command- the command to resolve the routing key for- Returns:
- the String representing the Routing Key, or
nullif unresolved
-
builder()