May Rest in Peace
May Rest in Peace

Reputation: 2197

Purpose of message brokers in websocket communication?

I am implementing websockets for collaborative editing. For that I am using Spring 5 websockets.

The simplest example would be, two web clients are connected via websockets to my server. User 1 does some action which creates an event and sends this event info to my server. Now this event has to be sent to User 2 so that they can do appropriate UI changes.

I have two questions here:

Just wanted to add: We cannot get away with a peer to peer connection on the client side as the server needs to store the data for future.

Upvotes: 3

Views: 3979

Answers (1)

Mykhailo Moskura
Mykhailo Moskura

Reputation: 2211

By default spring 5 uses in memory simple stomp broker for all connections If you want to scale horizontally you need a message broker like RabbitMQ etc. Lets imagine the situation user1 and user2 is connected to server1 and user3 is connected to server2 . When user1 sends a message to user3 it would not be aware of user3 because server1 does not know about user3. If we have a broker this issue will be solved. So scalability is needed to handle the load and in production you always will have more than 1 instance for high availability and fault tolerance.

Upvotes: 5

Related Questions