Subscription query - Emitter and QueryHandler in different JVM

Hello,
I have the same problem as described here spring boot - Axon - Cannot emit query update in different microservice - Stack Overflow. In my case three microservices: one for handling events (@EventHandler), one for commands, and one for queries (@QueryHandler). And the problem is that I only receive the initial query and no updates. But if I move the Emitter to the microservice with @QueryHandler then it works fine.

And I would like to ask, what is the best practice to solve this kind of situation? :slight_smile:

It’s partly answered on Stack Overflow already. You would need a distributed query bus to be able to query to another JVM. The only implementation currently is with Axon Server. So in the present situation, moving to Axon Server would be the only option.

As described in Stack Overflow, I am also using the Axon server and the AxonServerQueryBus. :slight_smile:

Hello Gerard, As Jan wrote - we are on Axon Server already, now testing on community edition - we will move soon to EE might this be the difference?

No, it should work with CE as well. I’m unsure what’s different in my first axon project. But there, I use SE of Axon Server and a different JVM for the emit query and calling the query, and it works.
The return type in SO is a Mono where I would expect a Flux, note that the reactive extension makes it easier, as I also did in the example project subscription. I hope this helps.

Hello Gerard,
I tried your example and there everything works fine but you have the @QueryHandler and @EventHandler with an emitter in the same JVM.

What I am talking about is the case where you have the @EventHandler with the emitter in a different JVM than @QueryHandler. In that case, the updates for the subscription query stop working.

That indeed doesn’t work. I do wonder why you would like to split handling events and queries, could you please explain? It’s not common to share databases between microservices, and you need the events to build a projection, so you can handle queries.