A header is required of every JMS message. The header contains ten predefined fields, which are listed and described in Table 2–3.
Table 2–3 JMS-Defined Message Header
As you can see from reading through this table, message header fields serve a variety of purposes: identifying a message, configuring the routing of messages, providing information about message handling, and so on.
One of the most important fields, JMSDeliveryMode, determines the reliability of message delivery. This field indicates whether a message is persistent.
Persistent messages. are guaranteed to be delivered and successfully consumed exactly once. Persistent messages are not lost if the message service fails.
Non-persistent messages are guaranteed to be delivered at most once. Non-persistent messages can be lost if the message service fails.
Some message header fields are set by the provider (either the broker or the client runtime) and others are set by the client. Message producers may need to configure header values to obtain certain messaging behaviors; message consumers may need to read header values in order to understand how the message was routed and what further processing it might need.
The header fields (JMSDeliveryMode, JMSExpiration, and JMSPriority) can be set at three different levels:
For messages issuing from every connection derived from a connection factory.
For each message produced.
For all messages issued by a specific message producer.
If these fields are set at more than one level, values set for the connection factory override those set for the individual message; values set for a given message override those set for the message’s producer.
Constant names for message header fields vary with the language implementation. See Sun Java System Message Queue 3.7 UR1 Developer’s Guide for Java Clients or Sun Java System Message Queue 3.7 UR1 Developer’s Guide for C Clients for more information.