O'Reilly logo

Java Message Service by Richard Monson-Haefel, David A Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Message Types

The Java Message Service defines six Message interface types that must be supported by JMS providers. Although JMS defines the Message interfaces, it doesn't define their implementation. This allows vendors to implement and transport messages in their own way, while maintaining a consistent and standard interface for the JMS application developer. The six message interfaces are Message and its five sub-interfaces: TextMessage, StreamMessage, MapMessage, ObjectMessage, and BytesMessage.

The Message interfaces are defined according to the kind of payload they are designed to carry. In some cases, Message types were included in JMS to support legacy payloads that are common and useful, which is the case with the text, bytes, and stream message types. In other cases, the Message types were defined to facilitate emerging needs; for example, ObjectMessage can transport serializable Java objects. Some vendors may provide other proprietary message types. Progress' SonicMQ and SoftWired's iBus, for example, provide an XMLMessage type that extends the TextMessage, allowing developers to deal with the message directly through DOM or SAX interfaces. The XMLMessage type may become a standard message type in a future version of the specification. At the time of this writing, Sun Microsystems was starting discussions about adding an XMLMessage type.

Message

The simplest type of message is the javax.jms.Message , which serves as the base interface to the other message types. As shown ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required