Facing :- --- org.axonframework.axonserver.connector.command.AxonServerCommandDispatchException(The command [ .CreateUserCommand] does not contain a routing key.

Hi All ,

I am facing below exception , I search in group , but went in vain .


@PostMapping(path = “/createUser”)
public void createUser(@RequestParam(name = “userName”)String userName,@RequestParam(name = “password”)String password) {

Hi Saranga,

The way you are sharing your information is, to be honest, far from ideal for anyone to deduce what the issue is.

I would highly recommend not just to drop entire snippets of code, but rather share the stack trace and versions of any of the tied in components in this set up.
However, you are lucky as I know exactly why it’s failing due to the title you have provided.

The exception is rather clear if you ask me, your command is missing a routing key.
There’s a short notice section called “Aggregate Creation Command Handlers” in the Reference Guide on it, as well as a more thorough description on the Routing Strategy you can specify.

What you are missing in the command payload you’ve created, is a @RoutingKey or @TargetAggregateIdentifier annotated field.

If you however are certain none of those belong there, which can be the case, then you’ll have to reconfigure your RoutingStrategy to Axon Server.

If you are in a Spring Boot environment, it’s as simple as providing a RoutingStrategy bean and the auto configuration will pick it up as desired.

You could for example replace the default AnnotationRoutingStrategy bean with an AnnotationRoutingStrategy instance using a different UnresolvedRoutingKeyPolicy.

Hope this sheds some lights on your options Saranga!


Steven van Beelen

Axon Framework Lead Developer

Axon in Action Award 2019 - Nominate your project