Explain the structure of a JMS message.

Answered

Explain the structure of a JMS message.

Ninja Asked on 19th September 2018 in JMS.
Add Comment
1 Answer(s)
Best answer

A JMS message has three parts – A header, properties and a body.

  1. A JMS message header contains a number of predefined fields like JMSDestination, JMSMessageID, JMSPriority etc. that contain values used by both clients and providers to identify and route messages.
  1. Message properties can be used if we want to send values in addition to those provided by header fields.
  1. The JMS API defines five message body types which helps in sending and receiving data in different forms:
    • TextMessage – Message body contains a text message an object of java.lang.String.
    • MapMessage – Message body contains a set of name-value pairs, with names as String objects and values as primitive types.
    • BytesMessage – Message body contains a stream of uninterpreted bytes which is used for literally encoding a body to match an existing message format.
    • StreamMessage – Message body contains a stream of primitive values, filled and read sequentially.
    • ObjectMessage – Message body contains a Serializable Java object.
    • Message – Message body contains nothing. This is composed of header fields and properties only. This message type is useful when a message body is not required.
Ninja Answered on 19th September 2018.
Add Comment