activemq.org › Handbook › STOMP protocol explained, with ActiveMQ, RabbitMQ and Python
HandbookSTOMP protocol explained, with ActiveMQ, RabbitMQ and Python
STOMP, the Simple (or Streaming) Text Orientated Messaging Protocol, is a small text-based wire protocol that lets clients in almost any language send and receive messages through a broker. Its frames look like HTTP requests (a command, headers, a blank line and a body), and both ActiveMQ Classic and RabbitMQ use port 61613 for it in their documented configurations.
This page covers the STOMP versions, the frame format, how to turn STOMP on in ActiveMQ Classic (it is commented out in the default configuration of 6.4.0 and 5.19.12), a Python example with stomp.py, RabbitMQ's STOMP plugin, and how STOMP compares with OpenWire, ActiveMQ's native protocol. The official ActiveMQ documentation is on activemq.apache.org; the protocol specification is published at stomp.github.io.
What is the STOMP protocol?
STOMP gives clients an interoperable wire format, so any STOMP client can talk to any STOMP broker. The specification says it arose from the need to reach enterprise message brokers from scripting languages such as Ruby, Python and Perl. It deliberately covers a small set of common messaging operations instead of a full messaging API, which makes a client quick to write. The STOMP site notes that you can even log in to a STOMP broker with telnet.
STOMP treats destination names as opaque strings and leaves their delivery semantics to the server. A name such as /queue/orders means whatever the broker decides, which is why ActiveMQ and RabbitMQ map destinations differently. Check your broker's documentation for its naming rules.
STOMP versions: 1.0, 1.1 and 1.2
| Version | What to know |
|---|---|
| 1.2 | The latest version, released 22 October 2012. Mostly backward compatible with 1.1, with two incompatible changes: frame lines may end with carriage return plus line feed, and message acknowledgement uses a dedicated header. The rest clarifies the 1.1 text. |
| 1.1 | Introduced version negotiation: from 1.1 on, the CONNECT frame must carry an accept-version header. Heart-beating, which checks that the TCP connection is still alive, applies to 1.1 and later. |
| 1.0 | The original version. A client that sends no accept-version header is treated as supporting only 1.0. |
During negotiation the client lists the versions it supports, and the session uses the highest version that client and server have in common.
The STOMP frame format
A frame starts with a command line, followed by zero or more key:value header lines, a blank line, an optional body and a NULL octet that ends the frame. The specification writes that NULL as ^@. Commands and header names are case sensitive, and commands and headers are encoded in UTF-8.
From the STOMP 1.2 specification, a client connecting:
CONNECT
accept-version:1.2
host:stomp.github.org
^@
The server's reply when it accepts:
CONNECTED
version:1.2
^@
And a message sent to a destination, also from the 1.2 specification:
SEND
destination:/queue/a
content-type:text/plain
hello queue a
^@
The frames you will meet:
- Client frames:
SEND,SUBSCRIBE,UNSUBSCRIBE,BEGIN,COMMIT,ABORT,ACK,NACKandDISCONNECT. - Server frames:
MESSAGE,RECEIPTandERROR. - Only
SEND,MESSAGEandERRORframes may have a body. Acontent-lengthheader is required if the body contains NULL octets. - Any client frame except
CONNECTcan carry areceiptheader; the server then confirms it with aRECEIPTframe. SUBSCRIBEtakes anackheader:auto(the default),client(cumulative acknowledgement) orclient-individual(one message at a time).
STOMP in ActiveMQ Classic
ActiveMQ supports STOMP together with a STOMP-to-JMS mapping, so a client written in Ruby, Perl, Python or PHP can exchange messages with Java JMS applications. The ActiveMQ STOMP page documents STOMP 1.1 compliance from ActiveMQ 5.6, with one noted exception about spaces at the start or end of header keys.
How to enable the STOMP connector on port 61613
In the conf/activemq.xml shipped with ActiveMQ 6.4.0, and in the one shipped with 5.19.12, only the OpenWire connector on port 61616 is enabled. A comment explains that additional transports are disabled by default to reduce the exposed attack surface, and the STOMP connector is present but commented out, so clients cannot connect on 61613 until you enable it. This is the line as it appears in both files:
<!-- <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=10485760"/> -->
Uncomment it: remove the surrounding <!-- and --> so the line sits active inside <transportConnectors>. The same file recommends the secured variants, such as stomp+ssl, in production. The ActiveMQ STOMP page also documents stomp+nio, which uses far fewer threads than the plain TCP connector. For every default port, see ActiveMQ ports.
Destinations, persistence and message types
- Destinations: ActiveMQ strips the
/queue/or/topic/prefix, so/queue/foo.baris the JMS queuefoo.bar. Avoid extra slashes:/queue/foo/barbecomes a queue calledfoo/bar. - Persistence: STOMP messages are non-persistent by default, the opposite of the JMS default. Add the header
persistent:trueto everySENDthat must survive a broker restart. - Message type: a frame with a
content-lengthheader becomes a JMSBytesMessage; without it, aTextMessage. - Durable topic subscriptions: send
client-idonCONNECTandactivemq.subscriptionNameonSUBSCRIBE. - Other ActiveMQ headers:
activemq.prefetchSizelimits unacknowledged messages per subscriber, andselectorapplies a JMS selector to a subscription.
Wire format, security and heart-beats
Wire format options must carry the wireFormat. prefix on the connector URI, or they are ignored. maxDataLength defaults to 104857600 bytes, and maxFrameSize exists from ActiveMQ 5.12.0. Since 5.1, a failed login makes CONNECT return an ERROR frame. For other operations you only get an error frame if you ask for receipts; otherwise a refused operation is dropped silently.
ActiveMQ supports heart-beating for clients on STOMP 1.1 or later. By default it enforces the client's read heart-beat interval strictly. From 5.9.0 you can add a grace period with the transport option transport.hbGracePeriodMultiplier, for example 1.5. Add trace=true to the connector URI to log STOMP frames while debugging.
Python STOMP client: stomp.py
stomp.py is a Python library for talking to a broker over STOMP, either from code or through its command-line client. Install it with pip:
pip install stomp.py
This example is the quick start from the stomp.py documentation (the version 8.3.0 pages, checked 6 December 2026). It connects to localhost on the default port, 61613, registers a listener, subscribes to /queue/test, sends the command-line arguments as a message and prints what comes back:
import time
import sys
import stomp
class MyListener(stomp.ConnectionListener):
def on_error(self, frame):
print('received an error "%s"' % frame.body)
def on_message(self, frame):
print('received a message "%s"' % frame.body)
conn = stomp.Connection()
conn.set_listener('', MyListener())
conn.connect('admin', 'password', wait=True)
conn.subscribe(destination='/queue/test', id=1, ack='auto')
conn.send(body=' '.join(sys.argv[1:]), destination='/queue/test')
time.sleep(2)
conn.disconnect()
Saved as stomptest.py, running python stomptest.py This is a test prints received a message "This is a test". The 'admin', 'password' pair is a placeholder; use the credentials your broker is configured with. The package also installs a command-line client, started with stomp -H localhost -P 61613, where you can type subscribe and send commands.
Against ActiveMQ Classic, remember the two defaults above: enable the STOMP connector first, and add the persistent:true header to sends that must survive a restart. For more ActiveMQ examples in Java and other languages, see the ActiveMQ tutorial.
RabbitMQ STOMP plugin
RabbitMQ supports STOMP through a plugin that ships in the core distribution and covers STOMP 1.0 through 1.2. The facts below come from the RabbitMQ 4.4 documentation. Enable it with:
rabbitmq-plugins enable rabbitmq_stomp
With no configuration, the plugin listens on all interfaces on port 61613, and its default login and passcode are guest / guest. A TLS listener can be added, for example on 61614. RabbitMQ maps destinations its own way, with /exchange, /queue, /amq/queue, /topic and /temp-queue/ forms, so STOMP code written for ActiveMQ may need its destination names changed. Frames are limited to 4 MB by default. For a broader comparison, see ActiveMQ vs RabbitMQ.
OpenWire: ActiveMQ's native protocol
OpenWire is the native protocol ActiveMQ uses. Per the ActiveMQ FAQ, it was first released in ActiveMQ 4.0 and is designed for performance and small size on the wire, giving up some ease of implementation to get there. STOMP takes the opposite trade: it is simple enough to implement in a few hours in any language, and a STOMP client is not as efficient as an OpenWire client.
| OpenWire | STOMP | |
|---|---|---|
| Format | Native ActiveMQ protocol, optimized for performance and size | Text frames modelled on HTTP |
| Client effort | Harder to implement | A few hours in any language; usable from telnet |
Default activemq.xml in 6.4.0 and 5.19.12 | Enabled, tcp://0.0.0.0:61616 | Commented out, stomp://0.0.0.0:61613 |
The default OpenWire connector uses plain, unencrypted TCP; the shipped file calls it intended for initial testing and strongly recommends the SSL variant for production. The two protocols interoperate on one broker: an OpenWire JMS producer can send to a STOMP consumer, and a STOMP producer to an OpenWire JMS consumer.
For history, the 2006 archive pages on OpenWire and STOMP are kept on this site; use the current documentation for configuration. For AMQP, the other standard protocol ActiveMQ speaks, see AMQP.
Common problems
- Connection refused on port 61613. In the default
activemq.xmlof 6.4.0 and 5.19.12 the STOMP connector is commented out. Uncomment it, or add your ownstomptransport connector. - Messages disappear after a broker restart. STOMP sends are non-persistent by default in ActiveMQ. Add
persistent:true. - A queue name contains slashes.
/queue/foo/barbecomes the queuefoo/bar. Use dots:/queue/foo.bar. - The broker drops the connection for missed heart-beats. Enforcement is strict unless you set
transport.hbGracePeriodMultiplier(5.9.0 or later). - A wire format option has no effect. It needs the
wireFormat.prefix. - Sends fail without any error. Request receipts; without them, authorization and other broker-side errors are not reported to the client.
Frequently asked questions
What is the STOMP protocol?
STOMP, the Simple (or Streaming) Text Orientated Messaging Protocol, is a text-based wire protocol with HTTP-like frames. Any STOMP client can talk to any STOMP broker, and a client is quick to write in almost any language.
What port does ActiveMQ use for STOMP?
ActiveMQ's documented STOMP connector uses port 61613. In the default activemq.xml of ActiveMQ 6.4.0 and 5.19.12 that connector is commented out, so you must uncomment it before STOMP clients can connect.
How do I use STOMP from Python?
Install the stomp.py library with pip install stomp.py, create a stomp.Connection, register a listener, connect, subscribe and send to a destination such as /queue/test. The library's quick start shows a complete example using port 61613.
Does RabbitMQ support STOMP?
Yes, through the rabbitmq_stomp plugin, which ships with RabbitMQ and supports STOMP 1.0 to 1.2. Enable it with rabbitmq-plugins enable rabbitmq_stomp; with no configuration it listens on port 61613.
What is the OpenWire protocol?
OpenWire is ActiveMQ's native wire protocol, first released in ActiveMQ 4.0 and designed for performance and small size on the wire. In the default configuration of ActiveMQ 6.4.0 it is the only enabled connector, on port 61616.
Related guides
- AMQP: 0-9-1 vs 1.0, and which brokers speak which
- ActiveMQ ports: defaults and how to change them
- ActiveMQ tutorial: send and receive your first messages
- ActiveMQ vs RabbitMQ: features, protocols and when to use each
- What is ActiveMQ?
- All handbook guides
From the 2006 archive
The original ActiveMQ documentation on these topics, kept as it was published here in 2004–2007. It describes ActiveMQ 4.x and older.
Sources
- STOMP: The Simple Text Oriented Messaging Protocol stomp.github.io
- STOMP Protocol Specification, Version 1.2 stomp.github.io
- ActiveMQ: STOMP activemq.apache.org
- ActiveMQ: How does OpenWire compare to Stomp activemq.apache.org
- ActiveMQ 6.4.0 default conf/activemq.xml (GitHub) raw.githubusercontent.com
- ActiveMQ 5.19.12 default conf/activemq.xml (GitHub) raw.githubusercontent.com
- stomp.py documentation: Quick start jasonrbriggs.codeberg.page
- RabbitMQ: STOMP Plugin www.rabbitmq.com