public class JmsMessageUtils extends Object
JmsMessageUtils contains helper method for dealing with JMS
messages in Mule.| Modifier and Type | Field and Description |
|---|---|
static char |
REPLACEMENT_CHAR |
| Constructor and Description |
|---|
JmsMessageUtils() |
| Modifier and Type | Method and Description |
|---|---|
static javax.jms.Message |
copyJMSProperties(javax.jms.Message from,
javax.jms.Message to,
JmsConnector connector) |
static String |
encodeHeader(String name)
Encode a String so that is is a valid JMS header name
|
static String |
getNameForDestination(javax.jms.Destination dest) |
static byte[] |
toByteArray(javax.jms.Message message,
String jmsSpec,
String encoding) |
static javax.jms.Message |
toMessage(Object object,
javax.jms.Session session) |
static Object |
toObject(javax.jms.Message source,
String jmsSpec,
String encoding) |
protected static boolean |
validateMapMessageType(Map<?,?> candidate)
MapMessage#writeObject(Object) accepts only primitives (and wrappers), String and byte[]. |
protected static boolean |
validateStreamMessageType(Object candidate)
StreamMessage.writeObject(Object) accepts only primitives (and wrappers), String and byte[]. |
public static final char REPLACEMENT_CHAR
public static String encodeHeader(String name)
name - the String to encodepublic static javax.jms.Message toMessage(Object object, javax.jms.Session session) throws javax.jms.JMSException
javax.jms.JMSExceptionpublic static Object toObject(javax.jms.Message source, String jmsSpec, String encoding) throws javax.jms.JMSException, IOException
javax.jms.JMSExceptionIOExceptionpublic static byte[] toByteArray(javax.jms.Message message,
String jmsSpec,
String encoding)
throws javax.jms.JMSException,
IOException
message - the message to receive the bytes from. Note this only works for
TextMessge, ObjectMessage, StreamMessage and BytesMessage.jmsSpec - indicates the JMS API version, either
JmsConstants.JMS_SPECIFICATION_102B or
JmsConstants.JMS_SPECIFICATION_11. Any other value
including null is treated as fallback to
JmsConstants.JMS_SPECIFICATION_102B.javax.jms.JMSException - if the message can't be read or if the message passed is
a MapMessageIOException - if a failure occurs while reading the stream and
converting the message datapublic static String getNameForDestination(javax.jms.Destination dest) throws javax.jms.JMSException
javax.jms.JMSExceptionpublic static javax.jms.Message copyJMSProperties(javax.jms.Message from,
javax.jms.Message to,
JmsConnector connector)
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected static boolean validateStreamMessageType(Object candidate)
StreamMessage.writeObject(Object) accepts only primitives (and wrappers), String and byte[].
An attempt to write anything else must fail with a MessageFormatException as per
JMS 1.1 spec, Section 7.3 Standard Exceptions, page 89, 1st paragraph.
Unfortunately, some JMS vendors are not compliant in this area, enforce here for consistent behavior.candidate - object to validateprotected static boolean validateMapMessageType(Map<?,?> candidate)
MapMessage#writeObject(Object) accepts only primitives (and wrappers), String and byte[].
An attempt to write anything else must fail with a MessageFormatException as per
JMS 1.1 spec, Section 7.3 Standard Exceptions, page 89, 1st paragraph.
Unfortunately, some JMS vendors are not compliant in this area, enforce here for consistent behavior.
Here we handle non-primitive maps as ObjectMessage rather than creating a MapMessagecandidate - Map to validateCopyright © 2003–2015 MuleSoft, Inc.. All rights reserved.