registering handlers in axonserver using multiple contexts


We are trying to set up axonserver with multiple contexts. 1 of these contexts is an “integration” context where all applications will publish milestone-events that other applications can subscribe to.

Everything seems to work fine except for the registration of commandhandlers/eventhandlers/queryhandlers. In the overview page these are all registered to the context of the primary AxonServerConfiguration. The other context has no registered handlers.
Eventhandlers seem to work as expected (receiving events from the correct context), but when i send a command from an application that uses a different context I get a “NoHandlerForCommandException: No Handler for command: GenereerDocumentIntegrationCommand”.

so basically I have the following problem:

  • Application A is trying to send a command U

  • Application B is connected to context X & Y

  • Application B has a commandhandler for command U registered to context Y (visible in overview screen on axonserver)

Application A is connected to context X and sends a command U => NoHandlerForCommandException
Aplication A is connected to context Y and sends a command U => command is processed by Application B

Is there a specific bean I need to use so that the commands/events/queries are registered to the correct context?

Kind Regards,
Ben Allaerts

doco context.png

doco context 2.png

This reply is a summary of the offline discussion with Ben and team.

Currently, multi-context support is not natively available in AxonFramework. This planned to be part of the 4.2 release. In that release, you can easily configure a different context as the source for a processor (thus reading events from another context), or as destination for commands and queries (thus sending them to another context).
An applictation is considered part of a single context, to which it will publish its processing information.

This behavior can (also in the current version) be completely overridden by manually configuring all the AxonServerConnector related beans. This is configuration beyond the ‘normal paths’, so check the AxonServerAutoConfiguration class for details on configuration.

We’re working hard to be able to publish the 4.2 release this month.