blob: 8149d6440e157b53703664a325acfc4dcc34c1ae [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ActiveMQ</title>
<link rel="icon" type="image/png" href="/assets/img/favicon.png">
<link rel="stylesheet" href="/css/main.css">
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js" integrity="sha384-SlE991lGASHoBfWbelyBPLsUlwY1GwNDJo3jSJO04KZ33K2bwfV9YBauFfnzvynJ" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light fixed-top">
<div class="container">
<!-- <a class="navbar-brand mr-auto" href="#"><img style="height: 50px" src="assets/img/apache-feather.png" /></a> -->
<a class="navbar-brand mr-auto" href="/"><img src="/assets/img/activemq_logo_black_small.png" style="height: 50px"/></a>
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="ml-auto collapse navbar-collapse" id="navbarContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link active" href="/index.html">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownComponents" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Components</a>
<ul class="dropdown-menu dropdown-menu-center" aria-labelledby="navbarDropdownComponents">
<div class="row">
<div class="col-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="/components/classic">ActiveMQ 5</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/artemis/">ActiveMQ Artemis</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/nms">NMS Clients</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/cms">CMS Client</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownCommunity" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Contact</a>
<ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownCommunity">
<div class="row">
<div class="col-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="/contact#mailing">Mailing Lists</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contact#chat">Chat</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contact#issues">Report Issues</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contact#contributing">Contributing</a></li>
<li class="nav-item"><a class="dropdown-item" href="/security-advisories.html">Security</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownTeam" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Apache</a>
<ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownTeam">
<div class="row">
<div class="col-sm-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org">The Apache Software Foundation</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/licenses/">License</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/thanks.html">Thanks</a></li>
<li class="nav-item"><a class="dropdown-item" href="/security-advisories.html">Security</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/events/current-event">Events</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://people.apache.org/phonebook.html?pmc=activemq">PMC & Committers</a></li>
<li class="nav-item"><a class="dropdown-item" href="/team/reports">Board Reports</a></li>
</ul>
</div>
</div>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="content">
<div class="page-title-activemq5">
<div class="container">
<h1>Stomp</h1>
</div>
</div>
<div class="container" >
<div class="row" style="margin-top: 30px">
<div class="col-12 activemq5">
<p><a href="connectivity">Connectivity</a> &gt; <a href="protocols">Protocols</a> &gt; <a href="stomp">Stomp</a></p>
<p>ActiveMQ supports the <a href="http://stomp.github.com/">Stomp</a> protocol and the Stomp - JMS mapping. This makes it easy to write a client in pure <a href="#">Ruby</a>, <a href="#">Perl</a>, <a href="#">Python</a> or <a href="#">PHP</a> for working with ActiveMQ.</p>
<p>Please see the <a href="http://stomp.github.io/">Stomp site</a> for more details</p>
<p>Spec Compliance</p>
<p>ActiveMQ v5.6 implements the Stomp v1.1 spec except for allowing spaces at the beginning or end of message header keys, they are preserved in the header values however. In future releases this will not be the case, clients should be updated and user code checked to ensure that spaces in the headers are there intentionally and not as a accident or a client “feature”.</p>
<h3 id="enabling-the-activemq-broker-for-stomp">Enabling the ActiveMQ Broker for Stomp</h3>
<p>To enable STOMP protocol support in the broker add a transport connector definition whose URI scheme is <code class="highlighter-rouge">stomp</code>.</p>
<p>Example:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;transportConnectors&gt;
&lt;transportConnector name="stomp" uri="stomp://localhost:61613"/&gt;
&lt;/transportConnectors&gt;
</code></pre></div></div>
<p>To see a full example, try <a href="http://svn.apache.org/repos/asf/activemq/trunk/assembly/src/release/example/conf/activemq.xml">this XML</a>. If you save that XML as <code class="highlighter-rouge">foo.xml</code> then you can run stomp via the command line as</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>activemq xbean:foo.xml
</code></pre></div></div>
<p>For more help see <a href="run-broker">Run Broker</a>.</p>
<h3 id="the-stomp-wire-format">The Stomp Wire Format</h3>
<p>Stomp uses a text based wire format that can be configured with the following options.  All options can be configured on a Brokers transport bind URI.</p>
<table>
<thead>
<tr>
<th>Parameter Name</th>
<th>Default Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="highlighter-rouge">maxDataLength</code></td>
<td><code class="highlighter-rouge">104857600</code></td>
<td>Maximum size of the message body (content) that can be sent.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">maxFrameSize</code></td>
<td><code class="highlighter-rouge">MAX_LONG</code></td>
<td><strong>From ActiveMQ 5.12.0</strong>: maximum frame size that can be sent. A Stomp frame includes a command, optional headers, and an optional body. Can help help prevent OOM DOS attacks</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;transportConnector name="stomp+ssl" uri="stomp+ssl://localhost:61612?wireFormat.maxFrameSize=1000000"/&gt;
</code></pre></div></div>
<blockquote>
<p><strong>Use the Correct Prefix!</strong></p>
<p>Wire format options must have the prefix <code class="highlighter-rouge">wireFormat.</code> to take effect, e.g., <code class="highlighter-rouge">wireFormat.`maxDataLength`=100000</code>. Options missing this prefix will be ignored.</p>
</blockquote>
<h3 id="security">Security</h3>
<p><strong>From ActiveMQ 5.1</strong>: Stomp fully supports <a href="security">ActiveMQ’s security</a> mechanism. This means that the <code class="highlighter-rouge">CONNECT</code> command will return an <code class="highlighter-rouge">ERROR</code> STOMP frame on unsuccessful authentication. Also, the authorization policies will be applied when you try to access (read/write) certain destinations. If you use synchronous operations (by using <a href="http://stomp.github.com/stomp-specification-1.1.html#RECEIPT">receipts</a>), you can expect an <code class="highlighter-rouge">ERROR</code> frame in case of unauthorized access attempt. In other case, operations will be discarded but the client will not be informed of errors. This applies to all errors that can occur broker-side.</p>
<blockquote>
<p><strong>SSL</strong></p>
<p>For additional security, you can use Stomp over SSL as described in the following section.</p>
</blockquote>
<h3 id="enabling-stomp-over-nio">Enabling Stomp over NIO</h3>
<p><strong>From ActiveMQ 5.3</strong>: for better scalability and performance the Stomp protocol can be configured to be run over the NIO transport. The <a href="http://activemq.apache.orgUsing ActiveMQ/configuring-transports.md#ConfiguringTransports-TheNIOTransport">NIO transport</a> will use far fewer threads than the corresponding TCP connector. This can help when support for a <a href="how-do-i-configure-10s-of-1000s-of-queues-in-a-single-broker">large number of queues</a> is required. To use NIO change the URI scheme of the transport connector to <code class="highlighter-rouge">stomp+nio</code>.</p>
<p>Example:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;transportConnector name="stomp+nio" uri="stomp+nio://localhost:61612"/&gt;
</code></pre></div></div>
<h3 id="enabling-stomp-over-ssl">Enabling Stomp over SSL</h3>
<p>To configure ActiveMQ to use Stomp over an SSL connection change the URI scheme to <code class="highlighter-rouge">stomp+ssl</code>.</p>
<p>Example:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;transportConnector name="stomp+ssl" uri="stomp+ssl://localhost:61612"/&gt;
</code></pre></div></div>
<p>For more details on using SSL with ActiveMQ see the following article (<a href="http://activemq.apache.org/how-do-i-use-ssl">How do I use SSL</a>). An example of using Stomp over SSL on the client side can be found in the <a href="http://stomp.fusesource.org/documentation/php/book.html#SSL">PHP Stomp client example</a>.</p>
<h3 id="heart-beat-grace-period">Heart-Beat Grace Period</h3>
<p>The STOMP protocol (version 1.1 or greater) <a href="http://stomp.github.io/stomp-specification-1.2.html#Heart-beating">defines the concept of heart beats</a> as a method by which a client and broker can determine the health of the underlying TCP connection between them. ActiveMQ supports STOMP heart beating provided the client is using version 1.1 (or greater) of the protocol.</p>
<p><strong>Before ActiveMQ 5.9.0</strong>: enforcement of the ‘read’ heart-beat timeout (that is, a heart-beat sent from the client to the broker) was strict. In other words, the broker was intolerant of late arriving read heart-beats from the client. This resulted in the broker concluding that the client was no longer present causing it to close its side of the client’s connection when the client failed to honor it’s configured heart-beat settings.</p>
<p><strong>From ActiveMQ 5.9.0</strong>: the timeout enforcement for read heart-beats is now configurable via a new transport option <code class="highlighter-rouge">transport.hbGracePeriodMultiplier</code>:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;transportConnectors&gt;
&lt;transportConnector name="stomp" uri="stomp://localhost:61613?transport.hbGracePeriodMultiplier=1.5"/&gt;
&lt;/transportConnectors&gt;
</code></pre></div></div>
<p>This multiplier is used to calculate the effective read heart-beat timeout the broker will enforce for each client’s connection. The multiplier is applied to the read-timeout interval the client specifies in its <code class="highlighter-rouge">CONNECT</code> frame:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;client specified read heart-beat interval&gt; * &lt;grace periodmultiplier&gt; == &lt;broker enforced read heart-beat timeout interval&gt;
</code></pre></div></div>
<p>For backward compatibility, if the grace period multiplier is not configured the default enforcement mode remains strict, e.g., <code class="highlighter-rouge">transport.hbGracePeriodMultiplier=1.0</code>. Attempts to configure the grace period multiplier to a value less than, or equal to <code class="highlighter-rouge">1.0</code> will be silently ignored.</p>
<p>STOMP clients that wish to be tolerant of late arriving heart-beats from the broker must implement their own solution for doing so.</p>
<ul>
<li>
<p>Please check the <a href="http://stomp.github.io/stomp-specification-1.2.html#Heart-beating">STOMP specification</a> for the details on heart-beating</p>
</li>
<li>
<p>The JIRA that implemented this: <a href="https://issues.apache.org/jira/browse/AMQ-4674">ActiveMQ 5.x does not support the notion of a grace-period for heart beats as supported by the STOMP protocol</a></p>
</li>
</ul>
<h3 id="working-with-destinations-with-stomp">Working with Destinations with Stomp</h3>
<p>Note that the prefix in stomp <code class="highlighter-rouge">/queue/</code> or <code class="highlighter-rouge">/topic/</code> is removed from the string before passing it to ActiveMQ as a JMS destination. Also note that the default separator in MOM systems is <code class="highlighter-rouge">.</code> (dot). Whilst <code class="highlighter-rouge">FOO.BAR</code> is the normal syntax to identify a queue type destination the Stomp equivalent is <code class="highlighter-rouge">/queue/FOO.BAR</code></p>
<blockquote>
<p><strong>Be careful about starting destinations with <code class="highlighter-rouge">/</code></strong></p>
<p>If in Stomp world you use <code class="highlighter-rouge">/queue/foo/bar</code> then in a JMS world the queue would be called <code class="highlighter-rouge">foo/bar</code> not <code class="highlighter-rouge">/foo/bar</code>.</p>
</blockquote>
<blockquote>
<p><strong>Persistent Messaging in STOMP</strong></p>
<p>STOMP messages are non-persistent by default. To use persistent messaging add the following STOMP header to all <code class="highlighter-rouge">SEND</code> requests: <code class="highlighter-rouge">persistent:true</code>. This default is the opposite of that for JMS messages.</p>
</blockquote>
<h3 id="working-with-jms-textbytes-messages-and-stomp">Working with JMS Text/Bytes Messages and Stomp</h3>
<p>Stomp is a very simple protocol - that’s part of the beauty of it! As such, it does not have knowledge of JMS messages such as <code class="highlighter-rouge">TextMessage</code>’s or <code class="highlighter-rouge">BytesMessage</code>’s. The protocol does however support a <code class="highlighter-rouge">content-length</code> header. To provide more robust interaction between STOMP and JMS clients, ActiveMQ keys off of the inclusion of this header to determine what message type to create when sending from Stomp to JMS. The logic is simple:</p>
<table>
<thead>
<tr>
<th>Inclusion of content-length header</th>
<th>Resulting Message</th>
</tr>
</thead>
<tbody>
<tr>
<td>yes</td>
<td><code class="highlighter-rouge">BytesMessage</code></td>
</tr>
<tr>
<td>no</td>
<td><code class="highlighter-rouge">TextMessage</code></td>
</tr>
</tbody>
</table>
<p>This same logic can be followed when going from JMS to Stomp, as well. A Stomp client could be written to key off of the inclusion of the <code class="highlighter-rouge">content-length</code> header to determine what type of message structure to provide to the user.</p>
<h3 id="message-transformations">Message Transformations</h3>
<p>The <code class="highlighter-rouge">transformation</code> message header on <code class="highlighter-rouge">SEND</code> and <code class="highlighter-rouge">SUBSCRIBE</code> messages could be used to instruct ActiveMQ to transform messages from text to the format of your desire. Currently, ActiveMQ comes with a transformer that can transform XML/JSON text to Java objects, but you can add your own transformers as well.</p>
<p>Here’s a quick example of how to use built-in transformer (taken from test cases)</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>private String xmlObject = "&lt;pojo&gt;\n"
+ " &lt;name&gt;Dejan&lt;/name&gt;\n"
+ " &lt;city&gt;Belgrade&lt;/city&gt;\n"
+ "&lt;/pojo&gt;";
public void testTransformationReceiveXMLObject() throws Exception {
MessageProducer producer = session.createProducer(new ActiveMQQueue("USERS." + getQueueName()));
ObjectMessage message = session.createObjectMessage(new SamplePojo("Dejan", "Belgrade"));
producer.send(message);
String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
frame = stompConnection.receiveFrame();
assertTrue(frame.startsWith("CONNECTED"));
frame = "SUBSCRIBE\n" + "destination:/queue/USERS." + getQueueName() + "\n" + "ack:auto" + "\n" + "transformation:jms-object-xml\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
frame = stompConnection.receiveFrame();
assertTrue(frame.trim().endsWith(xmlObject));
frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
}
</code></pre></div></div>
<blockquote>
<p><strong>Dependencies</strong></p>
<p>ActiveMQ uses <a href="http://xstream.codehaus.org">XStream</a> for its transformation needs. Since it’s the optional dependency you have to add it to broker’s classpath by putting the appropriate JAR into the <code class="highlighter-rouge">lib/</code> folder. Additionally, if you plan to use JSON transformations you have to add <a href="http://jettison.codehaus.org/">Jettison</a> JSON parser to the classpath.</p>
</blockquote>
<p>In order to create your own transformer, you have to do the following:</p>
<ol>
<li>
<p>Build your transformer by implementing a <a href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/transport/stomp/FrameTranslator.html">FrameTranslator</a> interface</p>
</li>
<li>
<p>Associate it with the appropriate header value by creating a file named as a value you want to use in the <code class="highlighter-rouge">META-INF/services/org/apache/activemq/transport/frametranslator/</code> folder of your JAR which will contain the value <code class="highlighter-rouge">class=_fully qualified classname of your transformer_</code></p>
</li>
</ol>
<p>For example the built-in transformer contains the following value:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>class=org.apache.activemq.transport.stomp.XStreamFrameTranslator
</code></pre></div></div>
<p>in the <code class="highlighter-rouge">META-INF/services/org/apache/activemq/transport/frametranslator/jms-xml</code> file.</p>
<h3 id="debugging">Debugging</h3>
<p>In case you want to debug Stomp communication between broker and clients you should configure the Stomp connector with the <code class="highlighter-rouge">trace</code> parameter, like this:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;transportConnectors&gt;
&lt;transportConnector name="stomp" uri="stomp://localhost:61613?trace=true"/&gt;
&lt;/transportConnectors&gt;
</code></pre></div></div>
<p>This will instruct the broker to trace all packets it sends and receives.</p>
<p>Furthermore, you have to enable tracing for the appropriate log. You can achieve that by adding the following to your <code class="highlighter-rouge">conf/log4j.properties</code></p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>log4j.logger.org.apache.activemq.transport.stomp=TRACE
</code></pre></div></div>
<p>Finally, you will probably want to keep these messages in the separate file instead of polluting the standard broker’s log. You can achieve that with the following log4j configuration:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>log4j.appender.stomp=org.apache.log4j.RollingFileAppender
log4j.appender.stomp.file=${activemq.base}/data/stomp.log
log4j.appender.stomp.maxFileSize=1024KB
log4j.appender.stomp.maxBackupIndex=5
log4j.appender.stomp.append=true
log4j.appender.stomp.layout=org.apache.log4j.PatternLayout
log4j.appender.stomp.layout.ConversionPattern=%d \[%-15.15t\] %-5p %-30.30c{1} - %m%n
log4j.logger.org.apache.activemq.transport.stomp=TRACE, stomp
log4j.additivity.org.apache.activemq.transport.stomp=false
# Enable these two lines and disable the above two if you want the frame IO ONLY (e.g., no heart beat messages, inactivity monitor etc).
#log4j.logger.org.apache.activemq.transport.stomp.StompIO=TRACE, stomp
#log4j.additivity.org.apache.activemq.transport.stomp.StompIO=false
</code></pre></div></div>
<p>After this, all your Stomp packets will be logged to the <code class="highlighter-rouge">data/stomp.log</code></p>
<h3 id="java-api">Java API</h3>
<p><strong>From ActiveMQ 5.2</strong>: there is a simple Java Stomp API distributed with ActiveMQ. Note that this API is provided purely for testing purposes and you should always consider using standard JMS API from Java instead of this one. The following code snippet provides a simple example of using this API:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>StompConnection connection = new StompConnection();
connection.open("localhost", 61613);
connection.connect("system", "manager");
StompFrame connect = connection.receive();
if(!connect.getAction().equals(Stomp.Responses.CONNECTED)) {
throw new Exception ("Not connected");
}
connection.begin("tx1");
connection.send("/queue/test", "message1", "tx1", null);
connection.send("/queue/test", "message2", "tx1", null);
connection.commit("tx1");
connection.subscribe("/queue/test", Subscribe.AckModeValues.CLIENT);
connection.begin("tx2");
StompFrame message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");
message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");
connection.commit("tx2");
connection.disconnect();
</code></pre></div></div>
<p>This example is part of the standard ActiveMQ distribution. You can run it from the <code class="highlighter-rouge">./example</code> folder with:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ant stomp
</code></pre></div></div>
<h3 id="stomp-extensions-for-jms-message-semantics">Stomp Extensions for JMS Message Semantics</h3>
<p>Note that STOMP is designed to be as simple as possible - so any scripting language/platform can message any other with minimal effort. STOMP allows pluggable headers on each request such as sending &amp; receiving messages. ActiveMQ has several extensions to the Stomp protocol, so that JMS semantics can be supported by Stomp clients. An OpenWire JMS producer can send messages to a Stomp consumer, and a Stomp producer can send messages to an OpenWire JMS consumer. And Stomp to Stomp configurations, can use the richer JMS message control.</p>
<p>STOMP supports the following standard JMS properties on <code class="highlighter-rouge">SENT</code> messages:</p>
<table>
<thead>
<tr>
<th>STOMP Header</th>
<th>JMS Header</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="highlighter-rouge">correlation-id</code></td>
<td><code class="highlighter-rouge">JMSCorrelationID</code></td>
<td>Good consumers will add this header to any responses they send.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">expires</code></td>
<td><code class="highlighter-rouge">JMSExpiration</code></td>
<td>Expiration time of the message.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">JMSXGroupID</code></td>
<td><code class="highlighter-rouge">JMSXGroupID</code></td>
<td>Specifies the <a href="message-groups">Message Groups.</a></td>
</tr>
<tr>
<td><code class="highlighter-rouge">JMSXGroupSeq</code></td>
<td><code class="highlighter-rouge">JMSXGroupSeq</code></td>
<td>Optional header that specifies the sequence number in the <a href="message-groups">Message Groups.</a></td>
</tr>
<tr>
<td><code class="highlighter-rouge">persistent</code></td>
<td><code class="highlighter-rouge">JMSDeliveryMode</code></td>
<td>Whether or not the message is persistent.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">priority</code></td>
<td><code class="highlighter-rouge">JMSPriority</code></td>
<td>Priority on the message.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">reply-to</code></td>
<td><code class="highlighter-rouge">JMSReplyTo</code></td>
<td>Destination you should send replies to.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">type</code></td>
<td><code class="highlighter-rouge">JMSType</code></td>
<td>Type of the message.</td>
</tr>
</tbody>
</table>
<h3 id="activemq-extensions-to-stomp">ActiveMQ Extensions to STOMP</h3>
<p>You can add custom headers to STOMP commands to configure the ActiveMQ protocol. Here are some examples:</p>
<table>
<thead>
<tr>
<th>Verb</th>
<th>Header</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="highlighter-rouge">CONNECT</code></td>
<td><code class="highlighter-rouge">client-id</code></td>
<td><code class="highlighter-rouge">string</code></td>
<td>Specifies the JMS clientID which is used in combination with the <code class="highlighter-rouge">activemq.subcriptionName</code> to denote a durable subscriber.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">SUBSCRIBE</code></td>
<td><code class="highlighter-rouge">activemq.dispatchAsync</code></td>
<td><code class="highlighter-rouge">boolean</code></td>
<td>Should messages be dispatched synchronously or asynchronously from the producer thread for non-durable topics in the broker? For fast consumers set this to <code class="highlighter-rouge">false</code>. For slow consumers set it to <code class="highlighter-rouge">true</code> so that dispatching will not block fast consumers.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">SUBSCRIBE</code></td>
<td><code class="highlighter-rouge">activemq.exclusive</code></td>
<td><code class="highlighter-rouge">boolean</code></td>
<td>I would like to be an <a href="exclusive-consumer">Exclusive Consumer</a> on the queue.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">SUBSCRIBE</code></td>
<td><code class="highlighter-rouge">activemq.maximumPendingMessageLimit</code></td>
<td><code class="highlighter-rouge">int</code></td>
<td>For <a href="slow-consumer-handling">Slow Consumer Handling</a> on non-durable topics by dropping old messages - we can set a maximum-pending limit, such that once a slow consumer backs up to this high water mark we begin to discard old messages.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">SUBSCRIBE</code></td>
<td><code class="highlighter-rouge">activemq.noLocal</code></td>
<td><code class="highlighter-rouge">boolean</code></td>
<td>Specifies whether or not locally sent messages should be ignored for subscriptions. Set to <code class="highlighter-rouge">true</code> to filter out locally sent messages.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">SUBSCRIBE</code></td>
<td><code class="highlighter-rouge">activemq.prefetchSize</code></td>
<td><code class="highlighter-rouge">int</code></td>
<td>Specifies the maximum number of pending messages that will be dispatched to the client. Once this maximum is reached no more messages are dispatched until the client acknowledges a message. Set to a low value &gt; <strong>1</strong> for fair distribution of messages across consumers when processing messages can be slow. <strong>Note</strong>: if your STOMP client is implemented using a dynamic scripting language like Ruby, say, then this parameter <strong><em>must</em></strong> be set to <code class="highlighter-rouge">1</code> as there is no notion of a client-side message size to be sized. STOMP does not support a value of <code class="highlighter-rouge">0</code>.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">SUBSCRIBE</code></td>
<td><code class="highlighter-rouge">activemq.priority</code></td>
<td><code class="highlighter-rouge">byte</code></td>
<td>Sets the priority of the consumer so that dispatching can be weighted in priority order.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">SUBSCRIBE</code></td>
<td><code class="highlighter-rouge">activemq.retroactive</code></td>
<td><code class="highlighter-rouge">boolean</code></td>
<td>For non-durable topics make this subscription <a href="retroactive-consumer">retroactive</a>.</td>
</tr>
<tr>
<td><code class="highlighter-rouge">SUBSCRIBE</code></td>
<td><code class="highlighter-rouge">activemq.subscriptionName</code></td>
<td><code class="highlighter-rouge">string</code></td>
<td>For durable topic subscriptions you must specify the same <code class="highlighter-rouge">activemq.client-id</code> on the connection and <code class="highlighter-rouge">activemq.subcriptionName</code> on the subscribe prior to v5.7.0. <strong>Note</strong>: the spelling <code class="highlighter-rouge">subcriptionName</code> NOT <code class="highlighter-rouge">subscriptionName</code>. This is not intuitive, but it is how it is implemented in ActiveMQ 4.x. For the 5.0 release of ActiveMQ, both <code class="highlighter-rouge">subcriptionName</code> and <code class="highlighter-rouge">subscriptionName</code> will be supported (<code class="highlighter-rouge">subcriptionName</code> was removed as of v5.6.0).</td>
</tr>
<tr>
<td><code class="highlighter-rouge">SUBSCRIBE</code></td>
<td><code class="highlighter-rouge">selector</code></td>
<td><code class="highlighter-rouge">string</code></td>
<td>Specifies a JMS Selector using SQL 92 syntax as specified in the JMS 1.1 specification. This allows a filter to be applied to each message as part of the subscription.</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row sitemap">
<div class="col-sm-12">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<div >
<img class="float-left" style="max-height: 100px" src="/assets/img/activemq_logo_white_vertical_small.png"/>
</div>
</div>
<div style="text-align: center; margin-bottom: 0px; margin-top: 30px; font-size: 65%" class="col-sm-6">
<p>Apache ActiveMQ, ActiveMQ, ActiveMQ Artemis, Apache, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright &copy; 2019, The Apache Software Foundation. Licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
</div>
<div class="col-sm-3">
<div >
<a href="https://www.apache.org"><img class="float-right" style="margin-top: 10px; max-height: 80px" src="/assets/img/apache-logo-small.png"/></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>