JmsMessageUtils (Mule ESB 2.2.1 API)
Keywords: org.mule.transport.jms.JmsMessageUtils class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule.transport.jms
Class JmsMessageUtils

    java.lang.Object
      org.mule.transport.jms.JmsMessageUtils

    public class JmsMessageUtils

extends Object

`JmsMessageUtils` contains helper method for dealing with JMS messages in Mule.

Field Summary
`static char` | `REPLACEMENT_CHAR`

Constructor Summary
`JmsMessageUtils()`

Method Summary
`static Message` | `copyJMSProperties(Message from, Message to, JmsConnector connector)`
`static String` | `encodeHeader(String name)` Encode a String so that is is a valid JMS header name
`static String` | `getNameForDestination(Destination dest)`
`static byte[]` | `toByteArray(Message message, String jmsSpec, String encoding)`
`static Message` | `toMessage(Object object, Session session)`
`static Object` | `toObject(Message source, String jmsSpec, String encoding)`
`protected static void` | `validateStreamMessageType(Object candidate)` `StreamMessage.writeObject(Object)` accepts only primitives (and wrappers), String and byte[].

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### REPLACEMENT_CHAR

    public static final char REPLACEMENT_CHAR

See Also:
  Constant Field Values

Constructor Detail

### JmsMessageUtils

    public JmsMessageUtils()

Method Detail

### encodeHeader

    public static String encodeHeader(String name)

  Encode a String so that is is a valid JMS header name

  Parameters:
    `name` - the String to encode
  Returns:
    a valid JMS header name

### toMessage

    public static Message toMessage(Object object,
                                    Session session)
                             throws JMSException

  Throws:
    `JMSException`

### toObject

    public static Object toObject(Message source,
                                  String jmsSpec,
                                  String encoding)
                           throws JMSException,
                                  IOException

  Throws:
    `JMSException`
    `IOException`

### toByteArray

    public static byte[] toByteArray(Message message,
                                     String jmsSpec,
                                     String encoding)
                              throws JMSException,
                                     IOException

  Parameters:
    `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`.
  Returns:
    a byte array corresponding with the message payload
  Throws:
    `JMSException` - if the message can't be read or if the message passed is a MapMessage
    `IOException` - if a failure occurs while reading the stream and converting the message data

### getNameForDestination

    public static String getNameForDestination(Destination dest)
                                        throws JMSException

  Throws:
    `JMSException`

### copyJMSProperties

    public static Message copyJMSProperties(Message from,
                                            Message to,
                                            JmsConnector connector)
                                     throws JMSException

  Throws:
    `JMSException`

### validateStreamMessageType

    protected static void validateStreamMessageType(Object candidate)
                                             throws MessageFormatException

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

  Parameters:
    `candidate` - object to validate
  Throws:
    `MessageFormatException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.