Hi,
We’re currently trying to set up Axon to achieve the following:
-
A central application which manages the aggregates and is responsible for command handling etc. (let’s call this the core for now)
-
Several instances of another application which communicates with external systems. (let’s call this the adapters for now)
-
Communication between these two using distributed command and event buses.
Communication using a distributed command bus is working perfectly. Basic communication using a distributed event bus (AMQP/RabbitMQ) is also working. We are now trying to solve the following problem: -
An external system tries to communicate with our system.
-
The external system hits the load balancer and one of the instances of the adapters receives this request.
-
This adapter registers the IP address of the external system and handles the request or sends a command to the core to handle this request.
-
Something happens in the core which requires communication with an external system.
-
The core publishes an event on the distributed event bus.
-
Only the adapter which already knows the external system and its IP address should receive this event and handle it.
Our problem right now is that last bullet. Our idea is using the following RabbitMQ topology: -
A (direct) exchange specifically for the messages from core to the adapters.
-
External system identifiers as routing keys.
-
One queue per external system which receives the events using the aforementioned routing keys.
Because we do not know beforehand which external system will contact us we need to dynamically create the above topology. This would give us completely separated instances of adapters which can easily be scaled out. If the load balancer decides to send messages from a specific external system to different adapters this wouldn’t be an issue either as it’ll be “first come, first serve” as to who will handle this event (which is fine for our solution).
We’ve got a small proof-of-concept which does the above using Spring AMQP but I’d like to use as much of Axon (and Axon AMQP) to recreate this so we can use all the nice stuff like annotated event listeners (instead of all the manual stuff we would have to do if we would only use Spring AMQP). I’m at a loss though as how to recreate this using Axon components (or integrate some of the manual Spring AMQP code into Axon components).
I think I would need to define clusters per external system and I think I’ll have to write a custom ClusterSelector to achieve this but honestly I’m grasping at straws here. Does anyone have any ideas, tips, or hints which could help us find a clean solution to this problem using Axon?
Regards,
Dennis Laumen