I'm working on a web application where connected users should receive real-time event notifications. By now it's pretty clear that I have to use web sockets, queues etc.... One challenge I'm facing is how an event generated in one web server is passed to clients connected to other web servers.
Tech used: React (Front End), Java (Spring) backend.
If it's just a web app then you might be able to do something using webRTC. create some 'rooms' and have a signalling server just for the initial connection. Could be worth looking into SIP and the architecture around that.
I would recommend that you don't actually build this system yourself unless you have a team and intend to market the real time system as a product to sell or if it's a personal project. There are so many things that can go wrong and to consider.
As a side note, as you're building this from scratch I would consider building it in either C++ or Go-lang. Both have significant execution times over Java.
In answer to your question specifically;
For each client you basically setup a WSS to the server. This then routes based on the target and payload. Bit like how people (the messages) changes trains (wss) in a train station (server/client).
a classic solution would be kafka for java devs.
producer -> queue -> consumer
that's how you send them between systems. a classic message bus. Or are there any special constraints?
Gijo Varghese
A WordPress speed enthusiast
In NodeJS, what I'll do is create multiple servers using SocketIO (a web socket library). Then create Redis server that all these servers will be connected. SocketIO has redis adapter. What it will do is, whenever there is a new event in a server, it's broadcasted to all other servers using Redis Pub/Sub.
In short: Use a Pub/Sub mechanism like Redis. Queues like Rabbitmq also have this feature