Enum Class UnresolvedRoutingKeyPolicy

java.lang.Object
java.lang.Enum<UnresolvedRoutingKeyPolicy>
org.axonframework.messaging.commandhandling.UnresolvedRoutingKeyPolicy
All Implemented Interfaces:
Serializable, Comparable<UnresolvedRoutingKeyPolicy>, Constable, RoutingStrategy

public enum UnresolvedRoutingKeyPolicy extends Enum<UnresolvedRoutingKeyPolicy> implements RoutingStrategy
Set of simple RoutingStrategy implementations.

Could for example be used as fallback solutions when another RoutingStrategy is unable to resolve the routing key.

Since:
2.0.0
Author:
Allard Buijze
  • Enum Constant Details

    • ERROR

      public static final UnresolvedRoutingKeyPolicy ERROR
      A RoutingStrategy which always throws a CommandDispatchException regardless of the CommandMessage received. Only feasible as a fallback solution which should straight out fail if the intended policy is unable to resolve a routing key.

      Note that when the routing key is based on static content in the CommandMessage, the exception raised should extend from AxonNonTransientException to indicate that retries do not have a chance to succeed.

      See Also:
    • RANDOM_KEY

      public static final UnresolvedRoutingKeyPolicy RANDOM_KEY
      Policy that indicates a random key is to be returned when no Routing Key can be found for a Command Message. This effectively means the Command Message is routed to a random segment.

      Although not required to be fully random, implementations are required to return a different key for each incoming command. Multiple invocations for the same command message may return the same value, but are not required to do so.

    • STATIC_KEY

      public static final UnresolvedRoutingKeyPolicy STATIC_KEY
      Policy that indicates a fixed key ("unresolved") should be returned when no Routing Key can be found for a Command Message. This effectively means all Command Messages with unresolved routing keys are routed to a the same segment. The load of that segment may therefore not match the load factor.
  • Method Details

    • values

      public static UnresolvedRoutingKeyPolicy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static UnresolvedRoutingKeyPolicy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • 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.