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:
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.
If a custom message transformer is defined for the bridge, pass the JMS message to the transformer's MessageTransformer.transform() method.
Send the message to its destination.
For JMS messages sent to a STOMP client, the STOMP bridge performs these tasks:
If a custom message transformer is defined for the bridge, pass the JMS message to the transformer's MessageTransformer.transform() method.
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.
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.
Send the message to the STOMP client.
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:
The formal parameters T and S must be of type javax.jms.Message.
" The source and target arguments will be either "STOMP" and "SUN_MQ" or "SUN_MQ" and "STOMP", respectively.
A source argument value of "STOMP" indicates that the message argument is from a STOMP client SEND frame received by the STOMP bridge.
A source argument value of "SUN_MQ" indicates that the message argument is from a Message Queue destination.
The readOnly argument will be false if the source argument is "STOMP" and true if the source argument is "SUN_MQ".
If the source argument is "STOMP", the properties argument contains, as key/value pairs, any arbitrary user headers that the STOMP bridge was unable to convert to JMS message properties in the message argument. Otherwise, the properties argument is null.
The charsetName argument should be ignored unless the source argument is "STOMP" and the message argument is a JMS BytesMessage message. This combination of argument values indicates that the message is from a STOMP client and has already been converted to a BytesMessage message.
The returned message must be in write-only mode if the source argument is "STOMP" and in read-only mode if the source argument is "SUN_MQ".