(03) ActiveMQ learning-2017/2/22

1. JMS message structure (message header)

A JMS message consists of the following parts: message header, attributes and message body

The message header contains the identification information and routing information of the message. The message header contains some standard attributes as follows:

1: JMSDestination: set by the send method

2: JMSDeliveryMode: set by the send method

3: JMSExpiration: set by the send method

4: JMSPriority: set by the send method

5: JMSMessageID: set by the send method

6: JMSTimestamp: set by client

7: JMSCorrelationID: set by the client

8: JMSReplyTo: set by the client

9: JMSType: set by the client

10: JMSRedelivered: set by the JMS Provider  

 

1.JMSDestination: Destination of message sending: mainly refers to Queue and Topic, automatically allocated

2.JMSDeliveryMode: delivery mode. There are two: persistent mode and non-persistent mode. A persistent message should be delivered "only once at a time", which means that if the JMS provider fails, the message is not lost, it will be delivered again after the server recovers. A non-persistent message is delivered at most once, which means the server fails and the message is lost forever. automatic allocation

3.JMSExpiration: message expiration time, equal to the timeToLive value in the send method of the Destination plus the GMT time value of the sending time. If the timeToLive value is equal to zero, JMSExpiration is set to zero, indicating that the message never expires. If, after sending, the message has not been sent to the destination after the message expiration time, the message is purged. automatic allocation

4.JMSPriority: message priority, ten levels from 0-9, 0-4 is normal message, 5-9 is urgent message. JMS does not require the JMS Provider to send messages strictly according to these ten priorities, but it must ensure that urgent messages arrive before ordinary messages. The default is level 4. automatic allocation 

5.JMSMessageID: Unique identification of each message, generated by the JMS Provider. automatic allocation

6.JMSTimestamp: A JMS Provider is automatically set when the send() method is called. It is the time difference between when the message is sent and the consumer actually receives it. automatic allocation

7.JMSCorrelationID: used to connect to another message, the typical application is to connect to the original message in the reply message. In most cases, JMSCorrelationID is used to mark a message as a reply to the previous message identified by JMSMessageID, however, JMSCorrelationID can be any value, not just JMSMessageID. Set by developer

8: JMSReplyTo: Provide the destination address of this message reply message. Set by developer

9: JMSType: Identifier of the message type. Set by developer

10: JMSRedelivered: If a client receives a message with the JMSRedelivered attribute set, it means that the client may have received the message earlier, but did not sign for it (acknowledged). If the message is redelivered, JMSRedelivered=true; otherwise, JMSRedelivered=false. auto configuration  

 

2. JMS message structure (message body)

Message body, JMS API defines 5 message body formats, also called message types, which can be sent in different forms

Receive data and be compatible with existing message formats. Includes: TextMessage, MapMessage, BytesMessage, StreamMessage, and ObjectMessage

Message properties, including the following three types of properties:

1: Properties set and added by the application, such as: Message.setStringProperty("username", username);

2: The properties defined by JMS use "JMSX" as the prefix of the property name connection.getMetaData().getJMSXPropertyNames(), the method returns the names of all JMSX properties supported by the connection.

3: JMS vendor specific properties

The properties defined by JMS are as follows:

1: JMSXUserID: User ID for sending the message, set by the provider when sending

2: JMSXAppID: The ID of the application sending the message, set by the provider when sending  

3. JMSXDeliveryCount: The number of retries to forward the message, the first time is 1, the second time is 2, ... , set by the provider when sending

4: JMSXGroupID: the identifier of the message group where the message is located, set by the client

5: JMSXGroupSeq: The sequence number of the messages in the group The first message is 1, the second is 2, ..., set by the client

6: JMSXProducerTXID: The transaction ID of the transaction that generated the message, set by the provider when sending

7: JMSXConsumerTXID: The transaction ID of the transaction that consumes the message, set by the provider when receiving

8: JMSXRcvTimestamp: The time when JMS forwards the message to the consumer, set by the provider when receiving

9: JMSXState: Assume there is a message store that stores a separate copy of each message from when the original message was sent. The status of each copy is: 1 (waiting), 2 (ready), 3 (expired) or 4 (reserved). Since state has nothing to do with producers and consumers, it is not provided by them. It's only related to looking up messages in the repository, so JMS doesn't provide this API. set by provider  

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326647448&siteId=291194637