Class MetadataRoutingStrategy

java.lang.Object
org.axonframework.messaging.commandhandling.MetadataRoutingStrategy
All Implemented Interfaces:
RoutingStrategy

public class MetadataRoutingStrategy extends Object implements RoutingStrategy
A 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.0
Author:
Allard Buijze
  • Constructor Details

    • MetadataRoutingStrategy

      public MetadataRoutingStrategy(String metadataKey)
      Instantiate a MetadataRoutingStrategy based on the fields contained in the give builder.

      Will assert that the metadataKey is not an empty String or null and will throw an AxonConfigurationException if this is the case.

      Parameters:
      metadataKey - The key in the Metadata to use for routing.
  • Method Details

    • getRoutingKey

      public String getRoutingKey(@Nonnull CommandMessage command)
      Description copied from interface: RoutingStrategy
      Generates a routing key for the given command.

      Commands that should be handled by the same segment, should result in the same routing key.

      Specified by:
      getRoutingKey in interface RoutingStrategy
      Parameters:
      command - The command to create a routing key for.
      Returns:
      The routing key for the command.