QueryUpdateEmitter on Multi-Noded Environment

Hello,

I am trying to see if we can use the QueryUpdateEmitter to feed updates of a projection to WebSocket connections, however we’re encountering an issue with multiple server nodes. The QueryUpdateEmitter only emits on the local server node.

We’ve considered processing the event on multiple server nodes, however as the projection backend is on the shared relational database, this leads to the projection being updated multiple times.

We’re stuck in a catch-22: when we process the event on a single node, the other nodes would not know what to emit for query updates… however if all nodes process the events, then the database is updated multiple times.

It appears that we need to build a shared queue to distribute the query update. Has anyone else managed to work around this limitation?

Thanks,
Wayne

Hi Wayne,

The quickest work around for this, would be to leverage Axon Server.

Axon Server will perform all the routing of your commands, event and queries, but also the command and query responses.
It is most certainly doable yourself though, we also have an issue open for this.

If you want to go down the path of building this, I’d recommend taking a look at how the DistributedCommandBus works.

Something similar could be done to create a DistributedQueryBus.

However, as pointed out at the start, the easiest solution would be to leverage Axon Server.

Cheers,
Steven

Thanks Steven.

Sadly, we opted out of using Axon Server due to keeping the deployment complexity to a minimum.

A concern with your approach is that this would force all all queries to be handled by a single node, which is also undesirably as it doesn’t distribute the load. We’ve thought of a couple other solutions (e.g.: Redis) but that would also increase the complexity.

I’ll take a look at the Distributed Command Bus though.

Thanks,
Wayne