Sun GlassFish Message Queue 4.4 Administration Guide

Message Processing Sequence Across the STOMP Bridge

The STOMP bridge processes messages differently depending on whether the message is a STOMP frame message being received from a STOMP client or a JMS message being sent to a STOMP client.

For STOMP frame messages received from a STOMP client, the STOMP bridge performs these tasks:

  1. Convert the STOMP frame message to a JMS BytesMessage if the content-length header is present; otherwise, convert it to a JMS TextMessage using UTF-8 as the message encoding.

  2. If a custom message transformer is defined for the bridge, pass the JMS message to the transformer's MessageTransformer.transform() method.

  3. Send the message to its destination.

For JMS messages sent to a STOMP client, the STOMP bridge performs these tasks:

  1. If a custom message transformer is defined for the bridge, pass the JMS message to the transformer's MessageTransformer.transform() method.

  2. If the transformed message (or original message when no custom transformer is defined) is not a JMS TextMessage or JMS BytesMessage message, close the STOMP connection and stop processing the message.

  3. Convert the JMS message to a STOMP frame message, using UTF-8 encoding for all headers and for the message body of a JMS TextMessage message.

  4. Send the message to the STOMP client.

Message Transformation During Message Processing

The message transformation between STOMP frame messages and JMS messages that the STOMP bridge automatically provides is sufficient in most applications. However, if you need to perform special processing or to send JMS message types other than BytesMessage or TextMessage to STOMP clients, you can define a custom message transformer for the STOMP bridge.

This custom message transformer is a Java class that extends the Message Queue Bridge MessageTransformer abstract class by implementing the class's transform() method. Then, place the class file in the IMQ_HOME/lib/ext directory and set the imq.bridge.stomp.messageTransformer broker property of the broker hosting the STOMP bridge to the fully qualified class name of the class.

When implementing the transform() method, keep these points in mind: