Sunday 5 August 2018

JMS: Headers

Header fields contains some important information, this is used by client and providers to identify and route messages.

Below table summarize JMS headers.

Header
Data Type
Description
JMSDestination
String
Specifies the destination to which the message is being sent.
JMSDeliveryMode
String
JMS supports two delivery modes.
a.   NON_PERSISTENT
b.   PERSISTENT

NON_PERSISTENT: Message is not stored in stable storage. A JMS provider failure can cause this message to be lost.

PERSISTENT: JMS message is stored in persistent storage. Message is not lost on JMS provider failures.
JMSMessageID
String
It is a unique ID, that uniquely identifies each message sent by a provider. All JMSMessageID values must start with the prefix 'ID:'.
JMSTimestamp
long
It represents the time a message was handed off to a provider to be sent. Time is represented in milliseconds.
JMSCorrelationID
string
It is used to link one message with another. Mostly it is used to link a response message with its related request message.

JMSCorrelationID can hold one of the following:
a.   A provider-specific message ID
b.   An application-specific String
c.   A provider-native byte[] value.


JMSReplyTo
string
It is the destination where a reply to the message should be sent. This header field is supplied by a client when a message is sent.
JMSRedelivered
boolean
Provider set this header field value to true, when it is redelivering the message to client.

When the provider set this flag to true, it means that the message is delivered previously, but provider do not receive any acknowledgement from the client.
JMSType
string
The JMSType header field contains a message type identifier supplied by a client when a message is sent.
JMSExpiration
long
Specifies the expiration time of the message. It is represented in milliseconds.

When a message is sent, the JMS provider calculates its expiration time by adding the time-to-live value specified on the send method to the time the message was sent.

Example
java.util.Date date = new java.util.Date();
long currentTimeInMillis = date.getTime();
long expiration = currentTimeInMillis + 60000;
message.setJMSExpiration(expiration);

Above statements set the expiration time to 1 minute.
JMSPriority
integer
Priority of the jms message. JMS defines 10 priority values from 0 to 9.

0 – Lowest priority
9 – Highest priority
JMSDeliveryTime
long
When a message is sent, the JMSDeliveryTime header field is left unassigned. After completion of the send or publish method, it holds the delivery time of the message

Not all these header fields are set by client, some are set by client and some are set by JMS provider. Below table summarizes this.

Header Field
Set By
Java API
JMSDestination
JMS provider send method
setJMSDestination (not for client use)
JMSDeliveryMode
JMS provider send method
setJMSDeliveryMode(not for client use)
JMSExpiration
JMS provider send method
setJMSExpiration
(not for client use)
JMSDeliveryTime
JMS provider send method
setJMSDeliveryTime
(not for client use)
JMSPriority
JMS provider send method
setJMSPriority
(not for client use)
JMSMessageID
JMS provider send method
setJMSMessageID
(not for client use)
JMSTimestamp
JMS provider send method
setJMSTimestamp
(not for client use)
JMSCorrelationID
Client application
setJMSCorrelationID, setJMSCorrelationIDAsBytes
JMSReplyTo
Client application
setJMSReplyTo
JMSType
Client application
setJMSType
JMSRedelivered
JMS provider prior to delivery
setJMSRedelivered
(not for client use)

Previous                                                 Next                                                 Home

No comments:

Post a Comment