Alright that clears it up a lot more for me, thanks!
The AxonServerCommandBus
, used by the CommandGateway
to send commands, is currently only connected to one context (let’s call it A). However, you want the command to be handled in context B.
You can supply a TargetContextResolver
to the AxonServerCommandBus
to resolve the context it has to send commands to. By default this resolves to context A
. Writing one that resolves this command to context B
should do the trick for you.
It should look like this:
@Configuration
public class AxonServerConfiguration {
@Bean
public TargetContextResolver<CommandMessage<?>> targetContextResolver() {
return message -> {
if(message.getCommandName().startsWith("de.tailord.workdutyplanning.api")) {
return "Context B";
}
return "Context A";
};
}
}
This bean is automatically picked up by the AxonServerAutoConfiguration