WebSphere MQ Everyplace messages are descendant objects of MQeFields, as described in Fundamental objects. Applications can put data into the message as a <name, data> pairing.
MQeMessages are specializations of MQeFields objects, therefore the functions that are applicable to MQeFields can be used with MQeMessage. An example of creating a message plus adding a fields is shown below. This is a function from one of the examples:
MQERETURN creatAMessage(MQeExceptBlock *pErrorBlock, MQeMsgHndl * phOutMsg) { MQERETURN rc; /* create a message obj */ rc = mqeMsg_new(pErrorBlock, phOutMsg); if (MQERETURN_OK == rc) { MQeStringHndl hDataFieldName; rc = mqeString_newChar8(pErrorBlock, &DataFieldName, "myData"); if (MQERETURN_OK == rc) { /* put some data in */ rc = mqeFields_putInt32((MQeFieldsHndl)*phOutMsg, pErrorBlock, hDataFieldName, 1); } else { displayError("new MQeString error (for data field name)", pErrorBlock); } } else { displayError("new MQeMsg error", pErrorBlock); } return rc; }
This shows a message being created, a new field name being created, and an integer being placed into the field. The field can be retrieved using the mqeField_getXXX functions.
WebSphere MQ Everyplace defines some constant field names that are useful to messaging applications. These are:
The Unique ID is a combination of a unique (per process) timestamp generated by the message object when it is created, and the name of the queue manager to which the message was first given. The Unique ID is used by applications to retrieve messages. It cannot be changed by an application.
The Unique ID uniquely identifies a message within an WebSphere MQ Everyplace network so long as all queue managers within the WebSphere MQ Everyplace network are named uniquely.
The mqeMsg_getMsgUIDFields() function accesses the Unique ID of a message:
The mqeMsg_getMsgUIDFields() function returns an MQeFields object that contains two fields,
These fields can be individually retrieved as follows:
The WebSphere MQ Message ID and Correlation ID fields allow the application to provide an identity for a message. These two fields are also used in interactions with the rest of the WebSphere MQ family.
The Priority field contains message priority values. Message priority is defined in the same way as in other members of the WebSphere MQ family. It ranges from 9 (highest) to 0 (lowest). Applications use this field to deal with a message according to its priority.