Multiple applications sharing same Event handlers

Hi Axon community,

One question. How does Axon decide which event handler to call if multiple applications or instances exist that implements the same event handler?

I’m currently working on a project where two applications shares the same aggregates and event handlers between them.
This is done by having a common maven-module with the aggregates and event handlers. Both applications uses the module

Which application will be handling the event when its fired? Are there risk that both applications picks up the event and the event handling thus happens twice?
And are there any load balancing?

Both applications is connected to the same database where events is stored. It is depending on the event processor? And the version of Axon (we use both Axon 2 and 4 currently).

Regards,
Theis

By the way, we use the default Spring Axon configuration. I see that it is pretty random which of the applications that picks up the handling of our events. But I’m not sure if it guaranteed that they isn’t handled twice (by same event handler).
We don’t use Axon Server.

It would be great to hear if any knows about this?

Have a look at: https://stackoverflow.com/questions/59694794/multiple-sagas-of-same-type-across-different-jvm-using-axon
You will get your answer.

I think, it would be great to add in documentation of Axon website a FAQ for all kind of questions asked on StackOverflow and this google group. Same questions are asked over and over.

Hi Yoann,

Thanks sharing the link. And great to see that you also faced the same concerns.
So I understand that we should use TrackingEventProcessor and it keeps track of that events was sent by using the shared database. I have also setup a TokenStore to use the entitymanager so both apps can connect.

Is this sufficient to guarantee that events only is processed once? Will Axon make sure to lock the Token table or similar while eventsHandles is triggered?
I also miss some description of the load-balancing strategy. How frequently does TrackingEventProcessor check the database?

Hi. I just found following small section in the documentation.
I believe it answered my original question: https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/event-processing/event-processors#multi-node-processing

Exactly, looks like many questions might have repeated here with different scenarios. Great idea to put them over Stackoverflow or Axon FAQ list and duplicate questions could be addressed.

Thanks,
Ravi Beli

Hi all,

As it stands we are trying to employ a form of FAQ (but with more added than just that) somewhere on the website.
Great to hear there’s interest in this from the community as well.

Cheers,

Steven van Beelen

Axon Framework Lead Developer

AxonIQ

twitter-icon_128x128.png