JMS entry (5)-Message Header

Source: Internet
Author: User

A message object is divided into three parts: headers, properties, and payload ). For streammessage and mapmessage, the message itself has a specific structure, while for textmessage, objectmessage and bytesmessage, there is no structure. A message can contain some important data or only notifications of an event.
The headers section of a message usually contains some message descriptions, which are standard descriptions. Contains the following values:
1) jmsdestination
The destination, topic, or queue of the message.
2) jmsdeliverymode

Message sending mode: Persistent or nonpersistent. The former indicates that a message exists after it is restarted if the JMS provider is down before it is consumed. In this case, the message will be lost. You can set the following method: producer. setdeliverymode (deliverymode. non_persistent );

3) jmstimestamp
When the send () method is called, jmstimestamp is automatically set as the current event. You can obtain this value using the following method:
Long timestamp = message. getjmstimestamp ();
4) jmsexpiration
Indicates the validity period of a message. The message consumer can consume the message only within the validity period. The default value is 0, indicating that the message never expires. You can set it in the following way:
Producer. settimetolive (3600000); // valid for 1 hour (1000 ms * 60 seconds * 60 minutes)
5) jmspriority
The priority of the message. 0-4 is the normal priority, and 5-9 is the high priority. You can set it as follows:
Producer. setpriority (9 );
6) jmsmessageid
A string uniquely identifies a message.
7) jmsreplyto
Sometimes the message producer wants the consumer to reply to a message, and jmsreplyto is a destination, indicating the destination to be replied. Of course, the consumer can ignore it.
8) jmscorrelationid
It is usually used to associate multiple messages. For example, to reply to a message, you can set jmscorrelationid to the jmsmessageid of the received message.
9) jmstype
Indicates the structure of the message body, which is related to the JMS provider.
10) jmsredelivered
If the value is true, the message is resent. Because sometimes the consumer does not confirm that he has received the message or the JMS provider is not sure whether the consumer has received the message.
In addition to the header, message senders can add properties ). These attributes can be application-defined attributes, JMS-defined attributes, and JMS-provider-defined attributes. Generally, we only apply custom attributes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.