What is STOMP?
STOMP is a simple, text-based messaging protocol that provides an interoperable wire format for message brokers. It defines a small set of commands (frames) for connecting, subscribing, sending, and disconnecting. Rhombus uses STOMP because it provides structured pub/sub messaging over a standard WebSocket transport.Frame Format
Every STOMP frame follows this structure:- COMMAND: A single word identifying the frame type (e.g.,
CONNECT,MESSAGE) - Headers: Zero or more
key:valuepairs, one per line - Empty line: Separates headers from body
- Body: Optional payload (typically JSON for MESSAGE frames)
- Null byte (
\x00): Terminates every frame
Example: Raw CONNECT Frame
Client-to-Server Frames
CONNECT
Initiates the STOMP session after the WebSocket connection is open.SUBSCRIBE
Subscribes to a destination topic to receive messages.The subscription
id is client-defined. Use any unique string. If you create multiple subscriptions, each must have a distinct id.DISCONNECT
Signals an intentional, clean disconnection.Server-to-Client Frames
CONNECTED
Sent by the server in response to a successful CONNECT.MESSAGE
Delivers an event from a subscribed topic.Heartbeats
Heartbeats keep the connection alive and detect failures. They are negotiated during the CONNECT/CONNECTED exchange.Format
A heartbeat is a single newline character:\n.
Negotiation
Theheart-beat header uses the format cx,cy where:
cx= minimum interval (ms) at which the client can send heartbeatscy= desired interval (ms) at which the client wants to receive heartbeats
10000,10000 (10 seconds both directions).
Behavior
Implementation
Frame Parsing Guide
Step-by-Step Parsing Algorithm
Edge Cases
Complete Frame Exchange
Here is the full frame sequence for a typical session:Differences from Full STOMP 1.2
The Rhombus implementation uses a subset of STOMP 1.2. Notable differences:
This means you do not need a full STOMP client library. The protocol subset is simple enough to implement manually, as shown in the Code Examples.