Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4BE22C5C7 for ; Fri, 7 Mar 2014 12:22:59 +0000 (UTC) Received: (qmail 21531 invoked by uid 500); 7 Mar 2014 12:22:58 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 20062 invoked by uid 500); 7 Mar 2014 12:22:54 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 19358 invoked by uid 99); 7 Mar 2014 12:22:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2014 12:22:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Mar 2014 12:22:47 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1357D238899C for ; Fri, 7 Mar 2014 12:22:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r900447 - in /websites/production/activemq/content: cache/main.pageCache stomp.html Date: Fri, 07 Mar 2014 12:22:27 -0000 To: commits@activemq.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140307122227.1357D238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: buildbot Date: Fri Mar 7 12:22:26 2014 New Revision: 900447 Log: Production update by buildbot for activemq Modified: websites/production/activemq/content/cache/main.pageCache websites/production/activemq/content/stomp.html Modified: websites/production/activemq/content/cache/main.pageCache ============================================================================== Binary files - no diff available. Modified: websites/production/activemq/content/stomp.html ============================================================================== --- websites/production/activemq/content/stomp.html (original) +++ websites/production/activemq/content/stomp.html Fri Mar 7 12:22:26 2014 @@ -82,161 +82,63 @@ -

ActiveMQ supports the Stomp protocol and the Stomp - JMS mapping. This makes it easy to write a client in pure Ruby, Perl, Python or PHP for working with ActiveMQ.

- -

Please see the Stomp site for more details

- -
+

ActiveMQ supports the Stomp protocol and the Stomp - JMS mapping. This makes it easy to write a client in pure Ruby, Perl, Python or PHP for working with ActiveMQ.

Please see the Stomp site for more details

Spec Compliance

Icon
- -

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".

+

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".

- - -

Enabling the ActiveMQ Broker for Stomp

- -

Its very easy to enable ActiveMQ for Stomp. Just add a connector to the broker using the stomp URL.

-
- -
-

To see a full example, try this XML. If you save that XML as foo.xml then you can run stomp via the command line as

-
- -
- -

For more help see Run Broker.

- - -

Security

- -

Stomp implementation fully supports an ActiveMQ security mechanism. This means that the CONNECT command will return an ERROR 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 receipts), you can expect an ERROR frame in case of unauthorized access attempt. In other case, operations will be discarded but the client will not be informed of errors. This also stands for all other errors that can happen on the broker side.

- -
+

For more help see Run Broker.

Security

Stomp implementation fully supports an ActiveMQ security mechanism. This means that the CONNECT command will return an ERROR 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 receipts), you can expect an ERROR frame in case of unauthorized access attempt. In other case, operations will be discarded but the client will not be informed of errors. This also stands for all other errors that can happen on the broker side.

Availability

Icon
- -

Stomp security implementation is available from version 5.1 onwards.

+

Stomp security implementation is available from version 5.1 onwards.

-

SSL

Icon
- -

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

+

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

- - -

Enabling Stomp over NIO

- -

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 file

- -
- -
- -

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

- -
+

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

Availability

Icon
- -

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

+

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

- - -

Enabling Stomp over SSL

- -

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

- -
- -
- - - - -

Heart-beat grace periods

- -

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 STOMP defined heart beating provided the client is using version 1.1 (or greater) of the protocol. Prior to ActiveMQ 5.9.0, however, the 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.

- -

As of version 5.9.0 the timeout enforcement for read heart-beats is now configurable via a new transport option,
-transport.hbGracePeriodMultiplier:

- -
- -
- -

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 CONNECT frame:

- -

<client specified read heart-beat interval> * <grace periodmultiplier> == <broker enforced read heart-beat timeout interval>

- -

For backward compatibility, if the grace period multiplier is not configured the default enforcement mode remains strict, e.g., transport.hbGracePeriodMultiplier=1.0. Attempts to configure the grace period multiplier to a value less than, or equal to 1.0 will be silently ignored.

- -

STOMP clients that wish to be tolerant of late arriving heart-beats from the broker must implement their own solution for doing so.

- - - - -

Working with Destinations with Stomp

- -

Note that the prefix in stomp /queue/ or /topic/ is removed from the string before passing it to ActiveMQ as a JMS destination. Also note that the default separator in MOM systems is . (DOT). So FOO.BAR is the normal syntax of a MOM queue - the Stomp equivalent would be /queue/FOO.BAR

-
+

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 CONNECT frame:

<client specified read heart-beat interval> * <grace periodmultiplier> == <broker enforced read heart-beat timeout interval>

For backward compatibility, if the grace period multiplier is not configured the default enforcement mode remains strict, e.g., transport.hbGracePeriodMultiplier=1.0. Attempts to configure the grace period multiplier to a value less than, or equal to 1.0 will be silently ignored.

STOMP clients that wish to be tolerant of late arriving heart-beats from the broker must implement their own solution for doing so.

Working with Destinations with Stomp

Note that the prefix in stomp /queue/ or /topic/ is removed from the string before passing it to ActiveMQ as a JMS destination. Also note that the default separator in MOM systems is . (DOT). So FOO.BAR is the normal syntax of a MOM queue - the Stomp equivalent would be /queue/FOO.BAR

Be careful about starting destinations with /

Icon
- -

If in Stomp world you use /queue/foo/bar then in a JMS world the queue would be called foo/bar not /foo/bar.

+

If in Stomp world you use /queue/foo/bar then in a JMS world the queue would be called foo/bar not /foo/bar.

- - -

Persistence of Stomp messages

- -

By default, Stomp produced messages are set to non-persistent. You have to explicitly tell your Stomp library to add "persistent:true" to all SEND requests, for any messages that you want to persist across ActiveMQ restarts. This is the opposite of the default for JMS submitted messages.

- -

Working with JMS Text/Bytes Messages and Stomp

- -

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 TextMessages or BytesMessages. The protocol does however support a content-length 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:

-

Inclusion of content-length header

Resulting Message

yes

BytesMessage

no

TextMessage

- -

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 content-length header to determine what type of message structure to provide to the user.

- -

Message transformations

- -

The transformation message header on SEND and SUBSCRIBE 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.

- -

Here's a quick example of how to use built-in transformer (taken from test cases)

- -
- -
- -
+

Dependencies

Icon
- -

ActiveMQ uses XStream 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 lib/ folder. Additionally, if you plan to use JSON transformations you have to add Jettison JSON parser to the classpath.

+

ActiveMQ uses XStream 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 lib/ folder. Additionally, if you plan to use JSON transformations you have to add Jettison JSON parser to the classpath.

- - -

In order to create your own transformer, you have to do the following:

- -
  1. Build your transformer by implementing a FrameTranslator interface
  2. Associate it with the appropriate header value by creating a file named as a value you want to use in the META-INF/services/org/apache/activemq/transport/frametranslator/ folder of your JAR which will contain the value class=full classname of your transformer
- - -

For example the built-in transformer contains the following value

- -
+

In order to create your own transformer, you have to do the following:

  1. Build your transformer by implementing a FrameTranslator interface
  2. Associate it with the appropriate header value by creating a file named as a value you want to use in the META-INF/services/org/apache/activemq/transport/frametranslator/ folder of your JAR which will contain the value class=full classname of your transformer

For example the built-in transformer contains the following value

-
- -

in the META-INF/services/org/apache/activemq/transport/frametranslator/jms-xml file.

- -

Message Ordering

- -

When delivering messages the broker uses the message-id to order them. This is based on the producer-id which, in the case of STOMP connections, is generated at the point that the producer connects to the broker.

- -

Therefore out-of-order messages may occur from a stomp application perspective. To give an example:

- -
  1. Producer p1 connects
  2. Producer p2 connects
  3. Producer p2 sends Message 1 to /queue/test
  4. Producer p1 sends Message 2 to /queue/test several seconds later
  5. Consumer c1 connects and subscribes to /queue/test and receives Message 2 followed by Message 1.
- - -

Debugging

- -

In case you want to debug Stomp communication between broker and clients you should configure the Stomp connector with the trace parameter, like this:

- -
- -
- -

This will instruct the broker to trace all packets it sends and receives.

- -

Furthermore, you have to enable tracing for the appropriate log. You can achieve that by adding the following to your conf/log4j.properties

- -
- -
- -

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:

- -
- -
- -

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

- -

Java API

- -

Since version 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:

- -
- -
- -

This example is distributed with the ActiveMQ distribution. You can run it from the example folder with

- -
- -
- -

Stomp extensions for JMS message semantics

- -

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 & 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.

- -

Stomp supports the following standard JMS properties on SENT messages:

-

Stomp header

JMS header

Description

correlation-id

JMSCorrelationID

Good consumers will add this header to any responses they send

expires

JMSExpiration

Expiration time of the message

persistent

JMSDeliveryMode

Whether or not the message is persistent

priority

JMSPriority

Priority on the message

reply-to

JMSReplyTo

Destination you should send replies to

type

JMSType

Type of the message

JMSXGroupID

JMSXGroupID

Specifies the Message Groups

JMSXGroupSeq

JMSXGroupSeq

Optional header that specifies the sequence number in the Message Groups

- - -

ActiveMQ extensions to Stomp

- -

You can add custom headers to Stomp commands to configure the ActiveMQ protocol. Here are some examples:

-

Verb

Header

Type

Description

CONNECT

client-id

string

Specifies the JMS Client ID which is used in combination with the activemq.subcriptionName to denote a durable subscriber.

SUBSCRIBE

selector

string

Specifies a JMS Selector using SQL 92 syntax as specified in the JMS 1.1 specificiation. This allows a filter to be applied to each message as part of the subscription.

SUBSCRIBE

activemq.dispatchAsync

boolean

Should messages be dispatched synchronously or asynchronously from the producer thread for non-durable topics in the broker? For fast consumers set this to false. For slow consumers set it to true so that dispatching will not block fast consumers.

SUBSCRIBE

activemq.exclusive

boolean

I would like to be an Exclusive Consumer on the queue.

SUBSCRIBE

activemq.maximumPendingMessageLimit

int

For Slow Consumer Handling 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.

SUBSCRIBE

activemq.noLocal

boolean

Specifies whether or not locally sent messages should be ignored for subscriptions. Set to true to filter out locally sent messages.

SUBSCRIBE

activemq.prefetchSize

int

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 1 for very fair distribution of messages across consumers where processing messages can be slow.

SUBSCRIBE

activemq.priority

byte

Sets the priority of the consumer so that dispatching can be weighted in priority order.

SUBSCRIBE

activemq.retroactive

boolean

For non-durable topics make this subscription retroactive.

SUBSCRIBE

activemq.subscriptionName

string

For durable topic subscriptions you must specify the same clientId on the connection and subcriptionName on t he subscribe.
- Note the spelling: subcriptionName NOT subscriptionName. This is not intuitive, but it is how it is implemented in ActiveMQ 4.x. For the 5.0 release of ActiveMQ, both subcriptionName and subscriptionName will be supported (subcriptionName removed as of v5.6.0)

+

Stomp extensions for JMS message semantics

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 & 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.

Stomp supports the following standard JMS properties on SENT messages:

Stomp header

JMS header

Description

correlation-id

JMSCorrelationID

Good consumers will add this header to any responses they send

expires

JMSExpiration

Expiration time of the message

persistent

JMSDeliveryMode

Whether or not the message is persistent

priority

JMSPriority

Priority on the message

reply-to

JMSReplyTo

Destination you should send replies to

type

JMSType

Type of the message

JMSXGroupID

JMSXGroupID

Specifies the Message Groups

JMSXGroupSeq

JMSXGroupSeq

Optional header that specifies the sequence number in the Message Groups

ActiveMQ extensions to Stomp

You can add custom headers to Stomp commands to configure the ActiveMQ protocol. Here are some examples:

Verb

Header

Type

Description

CONNECT

client-id

string

Specifies the JMS Client ID which i s used in combination with the activemq.subcriptionName to denote a durable subscriber.

SUBSCRIBE

selector

string

Specifies a JMS Selector using SQL 92 syntax as specified in the JMS 1.1 specificiation. This allows a filter to be applied to each message as part of the subscription.

SUBSCRIBE

activemq.dispatchAsync

boolean

Should messages be dispatched synchronously or asynchronously from the producer thread for non-durable topics in the broker? For fast consumers set this to false. For slow consumers set it to true so that dispatching will not block fast consumers.

SUBSCRIBE

activemq.exclusive

boolean

I would like to be an Exclusive Consumer on the queue.

SUBSCRIBE

activemq.maximumPendingMessageLimit

int

For Slow Consumer Handling on non-durable topics by dropping old messages - we can set a maximum-pending limit, such that once a slow consumer b acks up to this high water mark we begin to discard old messages.

SUBSCRIBE

activemq.noLocal

boolean

Specifies whether or not locally sent messages should be ignored for subscriptions. Set to true to filter out locally sent messages.

SUBSCRIBE

activemq.prefetchSize

int

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 1 for very fair distribution of messages across consumers where processing messages can be slow.

SUBSCRIBE

activemq.priority

byte

Sets the priority of the consumer so that dispatching can be weighted in priority order.

SUBSCRIBE

activemq.retroactive

boolean

For non-durable topics make this subscription retroactive.

SUBSCRIBE

activemq.subscriptionName

string

For durable topic subscriptions you must specify the same clientId on the connection and subcriptionName on the subscribe.
Note the spelling: subcriptionName NOT subscriptionName. This is not intuitive, but it is how it is implemented in ActiveMQ 4.x. For the 5.0 release of ActiveMQ, both subcriptionName and subscriptionName will be supported (subcriptionName removed as of v5.6.0)