Developing Java Applications with Spring and Spring Boot
by Claudio Eduardo de Oliveira, Greg L. Turnquist, Alex Antonov
Brokering WebSocket messages
Something that's important to understand is the flow of messages. So far, we have seen messages sent from the website into the comments service, stored into a MongoDB database, and then forwarded to our chat service.
At this point, we are trying to onramp these messages to WebSockets. But what does that mean? A WebSocket is a very lightweight, two-way channel between a web page and the server. WebSockets, on their own, don't dictate much about what travels over this thin pipe, but one thing is for certain--each web page, when connected to a server, has a separate session.
Spring WebFlux provides an API that lets us hook into this WebSocket-oriented session, whether to transmit or receive. But no WebSocket session ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access