If you’re using Axon 3 and Spring Boot, all you need to do is define a bean that implements RoutingKeyResolver. It gives you a message (an event) and expects you to return the String you want to use as routing key in AMQP.
If you don’t use Spring Boot, it is probably also enough to just define the bean, depending on how you have configured the SpringAMQPPublisher. Otherwise, you might have to explicitly set the RoutingKeyResolver on the SpringAMQPPublisher instance.