This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Stomp

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tip
titleSSL

For additional security, you can use Stomp over SSL as described in the following section.

Enabling Stomp over NIO

For From ActiveMQ 5.3: for better scalability ( and performance ) you might want to run Stomp protocol over NIO transport. To do that just use stomp+nio transport prefix instead of stomp. For example, add the following transport configuration in your XML filethe Stomp protocol can be configured to be run over the NIO transport. The NIO transport will use far fewer threads than the corresponding TCP connector. This can help when support for a large number of queues is required. To use NIO change the URI scheme of the transport connector to stomp+nio.

Example:

Code Block
xml
xml
<transportConnector name="stomp+nio" uri="stomp+nio://localhost:61612"/>

This transport use NIO transport underneath and will generally use much less threads than standard connector. This connector can help if you want to use large number of queues

Info
titleAvailability

Stomp NIO connector implementation is available in version 5.3 and up.

Enabling Stomp over SSL

It's easy to To configure ActiveMQ to use Stomp over an SSL connection . All you have to do is use change the URI scheme to stomp+ssl transport prefix instead of stomp. For example, add the following transport configuration in your XML file

Example:

Code Block
xml
xml
<transportConnector name="stomp+ssl" uri="stomp+ssl://localhost:61612"/>

For more details on using SSL with ActiveMQ see the following article (How do I use SSL).

...

An example of using Stomp over SSL on the client side

...

can be found in the PHP Stomp client example.

Heart-Beat Grace Period

The STOMP protocol (version 1.1 or greater) defines the concept of heart beats as a method by which a client and broker can determine the health of the underlying TCP connection between them. ActiveMQ offers support for supports STOMP defined heart beating provided the client is using version 1.1 (or greater) of the protocol.

...

After this, all your Stomp packets will be logged to the data/stomp.log

Java API

Since version From ActiveMQ 5.2, : 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:

Code Block
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();

This example is distributed with part of the standard ActiveMQ distribution. You can run it from the the ./example folder with:

Code Block
ant stomp

Stomp Extensions for JMS Message Semantics

...