IBM Integration Bus, Version 9.0.0.8 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS

See information about the latest product version

JMS message types

JMS defines six message interface types; a base message type and five subtypes. The message types are defined according to the type of the message payload, where the payload is the body of a message that holds the content.

JMS specifies only the interface and does not specify the implementation. This approach allows for vendor-specific implementation and transportation of messages while using a common interface.

The following table describes the six message types:
Message type Description
Message The base class. This message type is used for event notification, and does not have a payload.
BytesMessage The payload is stored as an array of bytes. This message type is useful for exchanging data in a format that is native to the application, and when JMS is used as a transport between two systems, where the JMS client does not know the message payload type. Use this message type to transmit XML messages to ensure that the message is transmitted efficiently, and is not subject to unnecessary data conversion.
TextMessage Data is stored as a string. This message type is useful for exchanging simple text messages.
StreamMessage A Stream message is a sequence of primitive Java™ types. The message object tracks the order and the types of these primitives within the stream. Formal conversion rules apply; for example, an exception is thrown if a JMS application tries to read a double value as a short value. Refer to the Java Message Service Specification, version 1.1 for a full list of the conversion rules.
21ABCDEFGH32.345 is an example of a StreamMessage payload. It consists of the following three fields:
  • An Integer, 21
  • A String, ABCDEFGH
  • A Float, 32.345

If the data structure is unknown, the generic method readObject() can be used to return the next object in the stream. If the structure of the data is known, the JMS client can be specific about the type of object being accessed.

MapMessage The payload of a MapMessage is stored as a set of name-value pairs. The name is defined as a string and the value is typed. The MapMessage is useful for delivering keyed data that can change from one message to the next.

NumberOfCopies:5 is an example of a MapMessage payload, where NumberOfCopies is the key and 5 is the value.

Data can be accessed by using getMapNames(), which returns a Java Enumeration object. It is possible to iterate through the MapMessage by using hasMoreElements() to retrieve the mapped name-value pairs.

ObjectMessage The Object message carries a serializable Java Object as its payload. It is useful for exchanging Java objects.

ac24862_.htm | Last updated Friday, 21 July 2017