First, preface
Some of the important concepts in JMS are described in detail in this article, mainly referring to the official JMS1.1 documentation, which is very old and 02, when Java was not acquired by Oracle. This article mainly introduces the message and its related concepts, because the official documents explained very detailed, so this is basically copied, just because of the time relationship, can not be fully translated, so this article only to say the focus.
Ii. composition of the message
Last interview, the interviewer asked me this question, but at that time was completely confused, used activemq several times, but each time is the next software, a service, and then on the Internet to find a template code configuration, you can receive the message OK, never to pay attention to. Now want to think, their technology has not been improved, and their own way of learning technology is related, know it, and do not know why.
To get to the point, the message consists of three parts, Header,properties and body, which are explained as follows:
Header: message header, all types of this part of the format are the same
Properties: Attributes, by type, can be divided into application settings properties, standard properties, and message middleware defined properties
Body: The message body refers to the content that we specifically need to transmit the message.
For illustrative purposes, the following table describes each property in the header
| Serial number |
Property name |
Description |
Set by |
1 |
Jmsdestination
|
The destination of the message sent is a topic or queue |
Send |
2 |
Jmsdeliverymode
|
The sending pattern of messages is divided into non_persistent and persistent, which are persistent and non-persistent |
Send |
3 |
Jmsmessageid
|
Message ID, need to start with ID: |
Send |
4 |
Jmstimestamp |
When a message is sent, it can also be understood as the time when the Send () method was called, not when the message was sent to completion |
Send |
5 |
Jmscorrelationid
|
The associated message ID, which is usually used when a callback message is required |
Client |
6 |
Jmsreplyto |
The destination of the message reply, whose value is a topic or queue, which is set by the sender, but the recipient can decide whether to respond |
Client |
7 |
Jmsredelivered |
If the message has been sent repeatedly, the value of this property needs to be set to true if the message was sent before, and the client can use the value of this property to Verify that the message has been sent repeatedly to avoid duplication of processing. |
Provider |
8 |
Jmstype
|
The message type set by the sender of the message, representing the structure of the message, some message middleware may use this, but this is not a kind of batch message, such as TextMessage or something. |
Client |
9 |
Jmsexpiration |
The expiration time of the message, in milliseconds, according to the definition, it should be the value of TimeToLive plus the GMT time when it was sent, which means that this refers to an expiration Time, not validity |
Send |
10 |
Jmspriority
|
Message priority, 0-4 is the normal optimization level, and 5-9 is a high priority, typically, high-optimized messages need to be sent first |
Send |
From the table above, we can see that the standard header information provided by the system has a total of 10 properties, of which 6 are set by the Send method at the time of invocation, three are set by the client, and one is set by the message middleware.
It should be noted that the client here is not the consumer, but refers to the use of JMS clients, namely the application written by developers, that is, in the production of messages, these three properties can be set by the application, and the other headers are either set by the message middleware, or by the sending method to decide, The developer is not valid even if it is set.
In order to verify our guess, the individual did a test, the result is as follows:
The above shows only the key setup codes and the print results after the consumer obtains the message, from which the following conclusions can be drawn:
1) only Jmstype, ReplyTo and Correlationid can display the settings, others are invalid
2) Priority and expiration date can be set by the producer
3) The value of expiration equals the timestemp time plus the TimeToLive value, which is an absolute time.
Based on the above conclusion, for most properties, we know the meaning of their representation, because we cannot change the settings of these values.
JMS Learning (ii)-JMS message Model composition and message header details