Using Message Descriptors

A Message Descriptor is an attribute representing a property of the message that is either being sent or received. Message properties can be the type of message, the message ID, and the message priority. For a detailed list of all the message descriptors supported by the MQSeries control, see Table 11-1, "Elements of the MQMDHeaders XML document".

Using the MQSeries control you can set Message Descriptors for each message while sending the message using the putMessage function. You can also get the message descriptors of the messages retrieved from the queue. This facility is supported using the MQMDHeaders document which is provided as an input to the putMessage and getMessage functions. The MQMDHeaders document is represented using an XMLBean that conforms to the MQMDHeaders schema present in the MQSchemas.jar file.

The following elements of the MQMDHeaders XML document can be set as part of the MQMD parameters:

Element Name
Description
Permissible Values
Relevance

MessageType

Type of message

8-Datagram

1-Request

2-Reply

Other positive integers are also accepted if they are within the Application or System defined ranges specified by MQSeries.

Put Request, Put Response, Get Response

MessageId

Id of message

Hexadecimal string

Put Request, Put Response, Get Request, Get Response

CorrelationId

Correlation Id of the message

Hexadecimal string

Put Request, Put Response, Get Request, Get Response

GroupMessage

This element is required to send and receive group messages.


Put Request, Put Response, Get Request, Get Response

GroupId

Group Id of the message

Hexadecimal string

Put Request, Put Response, Get Request, Get Response

Priority

Message priority

0-9

Put Request, Put Response, Get Response

Format

Message format

String values representing valid built-in MQSeries formats or user-defined formats. The string values are present in MQC.MQFMT_*.

Put Request, Put Response, Get Response

CharacterSet

Character Set of the message

Valid MQSeries Character set

Put Request, Put Response, Get Response

Persistence

Persistence property of the message

0- non-persistent message.

1-persistent message

Put Request, Put Response, Get Response

Segmentation

Segmentation property of the message

0- segmentation not allowed.

1- segmentation allowed.

Put Request

Expiry

Message expiration

A positive integer or -1 (for unlimited expiration)

Get Request, Put Response, Get Response

UserId

User Id of the message

A string

Put Request, Put Response, Get Response

MessageSequenceNumber

Message Sequence Number of the message

A positive integer, not 0

Put Request, Put Response, Get Request, Get Response

GroupOptions

use this element in the Put Request only if the message being Put is a group message. In the Get Response, this element appears only if the message retrieved is a group message.


Put Request, Get Response

IsLastMessage

Identifies the last message of a group message. This element accepts boolean values.

True or False

Put Request, Get Response

ReportOptions

Identifies the report options to be set while sending a message.


Put Request

COA

Confirmation on Arrival.

COA Report options

COA - the COA report without any original message data.

COAWithData-the COA report with the first 100 bytes of the original message.

COAWithFullData - the COA report with all the original message data.

COA, COAWithData, COAWithFullData, None

Put Request

COD

Confirmation of Delivery

COD Report options

COD - the COD report without any data of the original message.

CODWithData - the COD report with the first 100 bytes of the original message.

CODWithFullData - the COD report with all the original message data.

COD, CODWithData, CODWithFullData, None

Put Request

Exception

Exception Report options

Exception - the Exception report without any original message data.

ExceptionWithData - the Exception report with the first 100 bytes of the original message.

ExceptionWithFullData - the Exception report with all the original message data.

Exception, ExceptionWithData, ExceptionWithFullData, None

Put Request

Expiration

Expiration Report options

Expiration - the Expiration report without any original message data.

ExpirationWithData - the Expiration report with the first 100 bytes of the original message.

ExpirationWithFullData - The expiration report with all the original message data.

Expiration, ExpirationWithData, ExpirationWithFullData, None

Put Request

Feedback

Message feedback

A positive integer

Put Request, Put Response, Get Response

ReplyToQueueName

The queue to which the reports or the reply (used only for a request message) should be sent.

String representing a valid queue name

Put Request, Put Response, Get Response

ReplyToQueueManager

The queue manager containing the reply to queue.

String representing a valid queue manager name

Put Request, Put Response, Get Response

WaitInterval

The lapse time (in milliseconds) before receiving a message.

A positive integer. -1 for unlimited wait interval

Get Request

ApplicationIdData


String value

Put Request, Put Response and Get Response.

ApplicationOriginData


String value

Put Request, Put Response and Get Response.

PutApplType

Put application type of the message

Positive integer value

Put Request, Put Response and Get Response.

PutApplName

Put application name of the message

String value

Put Request, Put Response and Get Response.

PutDateTime

Put date and time of the message

String value

Put Response and Get Response

AccountingToken

Accounting information for the message

Byte array

Put Request, Put Response and Get Response.

Version

Version information of the message descriptor

2 or 1

Put Request, Put Response and Get Response.

MessageConsumption

Message consumption option for the getMessage function.

Browse - Retrieve the message from the queue (without deleting the message).

Delete - Delete the message from the queue after retrieving it.

Browse, Delete

Get Request

MQGMO_CONVERT

Specifies whether data conversion is required for the message during a Get operation.

This element must be set to True to retrieve messages of the EBCDIC characterset.

True or False

Get Request

Attribute Name
Under Element
Description
Values
Relevance

waitForAllMsgs

GroupMessage

Used while retrieving group messages to specify that no message of the group should be retrieved until all the messages of the group are available in the queue. This attribute is normally specified only while retrieving the first message of the group.

True or False

Get Request and Get Response

logicalOrder

GroupMessage

Used while retrieving group messages to specify that the messages of the group should be retrieved in the order of their Message Sequence Number irrespective of the order in the queue. This option is specified while retrieving all the messages of the group.

True or False

Get Request and Get Response

Schema of the MQMDHeaders Document

<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.bea.com/wli/control/MQMDHeaders"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.bea.com/wli/control/MQMDHeaders" elementFormDefault="qualified">
<xs:element name="MQMDHeaders">
     <xs:complexType>
          <xs:sequence>
<xs:element name="MessageType" type="xs:string" minOccurs="0"
maxOccurs="1"/>
<xs:element name="MessageId" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="CorrelationId" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="GroupMessage" minOccurs="0" maxOccurs="1"> <xs:complexType>
     <xs:sequence>
<xs:element name="GroupId" type="xs:string" minOccurs="1" maxOccurs="1"/>
          </xs:sequence>
<xs:attribute name="waitForAllMsgs" type="xs:boolean" use="optional"/>
<xs:attribute name="logicalOrder" type="xs:boolean" use="optional"/>
     </xs:complexType>
          </xs:element>
<xs:element name="Priority" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="Format" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="CharacterSet" type="xs:string" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Persistence" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="Segmentation" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="Expiry" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="UserId" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="MessageSequenceNumber" type="xs:string" minOccurs="0"
maxOccurs="1"/>
<xs:element name="GroupOptions" minOccurs="0" maxOccurs="1">
     <xs:complexType>
          <xs:sequence>
               <xs:element name="IsLastMessage" type="xs:boolean" minOccurs="1" maxOccurs="1"/>
          </xs:sequence>
     </xs:complexType>
</xs:element>
<xs:element name="ReportOptions" minOccurs="0" maxOccurs="1">
     <xs:complexType>
     <xs:sequence>
     <xs:element name="COA" type="xs:string" minOccurs="0" maxOccurs="1"/>
     <xs:element name="COD" type="xs:string" minOccurs="0" maxOccurs="1"/>
     <xs:element name="Exception" type="xs:string" minOccurs="0" maxOccurs="1"/> 
     <xs:element name="Expiration" type="xs:string" minOccurs="0" maxOccurs="1"/> 
     </xs:sequence>
     </xs:complexType>
     </xs:element> 
<xs:element name="Feedback" type="xs:int" minOccurs="0" maxOccurs="1"/> <xs:element name="ReplyToQueueName" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="ReplyToQueueManager" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="WaitInterval" type="xs:string" minOccurs="0" maxOccurs="1"/> 
<xs:element name="ApplicationIdData" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="ApplicationOriginData" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="PutApplType" type="xs:int" minOccurs="0" maxOccurs="1"/>
<xs:element name="PutApplName" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="PutDateTime" type="xs:string" minOccurs="0" maxOccurs="1"/> 
<xs:element name="AccountingToken" type="xs:base64Binary" minOccurs="0" maxOccurs="1"/> 
<xs:element name="Version" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="MessageConsumption" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="MQGMO_CONVERT" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema> 

Sample of an MQMDHeaders Document

The following is a sample MQMDHeaders document that contains most of the message descriptors you can set using the MQSeries control:

<?xml version="1.0"?>
<even:MQMDHeaders xmlns:even="http://www.bea.com/wli/control/MQMDHeaders">
<even:MessageType>8</even:MessageType>
<even:MessageId>1111</even:MessageId> <even:CorrelationId>2222</even:CorrelationId>
<even:GroupMessage>
     <even:GroupId>3333</even:GroupId>
</even:GroupMessage>
<even:Priority>9</even:Priority>
<even:Format>MQSTR</even:Format> <even:CharacterSet>819</even:CharacterSet> <even:Persistence>1</even:Persistence> <even:Segmentation>1</even:Segmentation>
<even:Expiry>5000</even:Expiry>
<even:UserId>WebLogic</even:UserId> <even:MessageSequenceNumber>1</even:MessageSequenceNumber> <even:GroupOptions>
     <even:IsLastMessage>true</even:IsLastMessage>
</even:GroupOptions>
<even:ReportOptions>
     <even:COA>COAWithFullData</even:COA>
     <even:COD>CODWithFullData</even:COD>
     <even:Exception>ExceptionWithFullData</even:Exception>
     <even:Expiration>ExpirationWithFullData</even:Expiration> </even:ReportOptions>
<even:Feedback>1</even:Feedback>
<even:ReplyToQueueName>trial</even:ReplyToQueueName> <even:ReplyToQueueManager>QM_itpl_025051</even:ReplyToQueueManager> <even:ApplicationIdData>App_ID_025051</even:ApplicationIdData> <even:ApplicationOriginData>Windows_app_025051</even:ApplicationOriginData> <even:PutApplType>1</even:PutApplType> <even:PutApplName>MQSeriesClient</even:PutApplName> <even:Version>2</even:Version>
</even:MQMDHeaders> 

Using XML Beans to Set the MQMDHeader Element Values

The MQSeries control MQMDHeaders document element values can be set, and the return values can be retrieved, programmatically, using XML beans. The following is an example of setting the MQMDHeader element values prior to calling the putMessage function:

headers = com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument.Factory.newInstance();com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument.MQMDHeaders header = headers.addNewMQMDHeaders();
header.setMessageType(MQC.MQMT_DATAGRAM);
header.setPriority(8);
header.setExpiry(5000);
header.setPersistence(MQC.MQPER_PERSISTENT);
header.getReportOptions().setCOA("COA"); header.setReplyToQueueName("ReportQueue"); header.setApplicationIdData("Testing"); header.setApplicationOriginData("AAAA");
header.setPutApplName("Websphere MQ 2"); header.setPutApplType(MQC.MQAT_JAVA);  
Previous Document Next Document