Detect if a User is Online with RabbitMQ Web Stomp
Posted by
Brad Wood
Mar 13, 2021 00:41:00 UTC
We're using RabbitMQ and its Web Stomp plugin for websockets for several projects at work. Using a Stomp.js library in the browser, our app users connect and subscribe to topics using their username and JWT, which we validate using a custom HTTP back end auth in Rabbit. I've recently written a rest-over-stomp module for ColdBox MVC which allows you to push the response of any Coldbox event or API call out over a websocket channel to any browser listening on that channel. This allows for the following
- Browser can request data and receive it async
- Any random server-side process can simply decide to push fresh data out to browser
- Each user subscribes to a custom topic specific to them (via permissions enforced by my custom HTTP backend auth) so I have a direct data bus to any users's browser
- Unlike Ajax calls, there is no HTTP/TCP negotiation of each request since the websocket is a persistent connection to the server