What are JMS messages?
Created May 4, 2012
Jerry Smith
JMS messages implement the Message interface.
JMS messages include a header, properties, and the message body. Headers provide identifying and routing information. Properties allow arbitrary ornamenting of messages with application-specific markers or tags. Receiving clients can select, or filter, messages based on properties.
The message body is available in five flavors:
- StreamMessage - a stream of Java primitive values
- MapMessage - a set of name-value pairs
- TextMessage - a String object
- ObjectMessage - a serialzed Java object
- BytesMessage - a stream of uninterpreted bytes
To obtain a message of the requisite type, make a request via the appropriate create method, for example:
TextMessage message = session.createTextMessage();
Note that some vendors provide additional message types.