What is STOMP protocol and how is it used with WebSockets?

Answer

STOMP (Simple Text Oriented Messaging Protocol) is a simple, interoperable protocol originally designed for message brokers (like ActiveMQ, RabbitMQ). It defines a frame-based messaging protocol with commands like CONNECT, SUBSCRIBE, SEND, and DISCONNECT. When used over WebSockets, STOMP adds a structured messaging layer on top of the raw WebSocket transport, enabling integration with enterprise message brokers. A Spring Boot application with spring-websocket and spring-messaging naturally speaks STOMP over WebSocket — the client subscribes to topics (/topic/updates) and the server broadcasts messages to those topics. The SockJS client library (often paired with STOMP) provides WebSocket with HTTP fallbacks. This stack is popular in Java enterprise applications that need real-time features integrated with existing messaging infrastructure.