A Message Descriptor is an attribute representing a property of the message, that is either being sent or received. For example, the Message Type of the message, the Message ID of the message, and the Priority of the message. For a detailed listing of all the message descriptors that are supported by the MQSeries control, see Table 10-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 message that are retrieved from the queue. This facility is supported with the help of the MQMDHeaders document which is provided as an input to the putMessage and getMessage functions. The MQMDHeaders document is represented using an XMLBean, which conforms to the MQMDHeaders schema which is present in the MQSchemas.jar.
The following elements of the MQMDHeaders XML document can be set as part of the MQMD parameters:
<?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>
The following is a sample MQMDHeaders document that contains most of the message descriptors that you can set using 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>
The MQSeries control MQMDHeaders document element values can be set and the return values can be retrieved, programmatically, by using XML beans. An example for setting the MQMDHeader element values prior to the putMessage function call is as follows:
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);
![]() |
![]() |