0Pricing
WebSockets & Real-Time Systems with Spring · Lesson

Implementing Public Chat Rooms

Develop functionality for users to join and participate in public, broadcast-style chat rooms.

Public Chat Rooms Explained

Welcome! In this lesson, we'll build public chat rooms. These are common spaces where many users can send and receive messages, visible to everyone in that room.

Think of a general discussion channel in a messaging app. The key characteristic here is broadcast communication: one message sent by any user is instantly relayed to all other users currently in the room.

STOMP Topics for Rooms

In Spring with STOMP, we use topics to represent chat rooms. A topic is like a channel clients can subscribe to. Messages sent to a topic are broadcast to all its subscribers.

  • For public rooms, we often use a common topic path like /topic/public-chat.
  • Clients subscribe to this topic to receive messages.
  • Clients send messages to a specific application destination, which the server then forwards to the topic.

All lessons in this course

  1. Designing a Chat Message Model
  2. Implementing Public Chat Rooms
  3. Private Messaging with STOMP
  4. Typing Indicators & Online Presence
← Back to WebSockets & Real-Time Systems with Spring