When you receive a message, if you are interested in the message properties, you need to obtain a handle to the properties object associated with that message:
Use the MQGetMessageProperties function to obtain a handle to the properties object for user-defined properties.
If you are interested in any message header properties, use the MQGetMessageHeaderProperties function to obtain a handle to the header properties. See MQGetMessageHeaders.
Having obtained the handle, you can iterate through the properties and then use the appropriate MQGet...Property function to determine the type and value of each property.
Table 2–2 lists the functions you use to iterate through a properties handle and to obtain the type and value of each property.
Table 2–2 Functions Used to Get Message Properties
Function |
Description |
Starts the iteration process through the specified properties handle. |
|
Returns MQ_TRUE if there are additional property keys left in the iteration. |
|
Passes back the address of the next property key in the referenced property handle. |
|
Gets the type of the specified property. |
|
Gets the value of the specified MQBool type property. |
|
Gets the value of the specified MQString type property. |
|
Gets the value of the specified MQInt8 type property. |
|
Gets the value of the specified MQInt16 type property. |
|
Gets the value of the specified MQInt32 type property. |
|
Gets the value of the specified MQInt64 type property. |
|
Gets the value of the specified MQFloat32 type property. |
|
Gets the value of the specified MQFloat64 type property. |
Start the process by calling the MQPropertiesKeyIterationStart() function.
Loop using the MQPropertiesKeyIterationHasNext() function.
Extract the name of each property key by calling the MQPropertiesKeyIterationGetNext() function.
Determine the type of the property value for a given key by calling the MQGetPropertyType() function.
Use the appropriate MQGet...Property function to find the value of the specified property key and type.
If you know the property key, you can just use the appropriate MQGet...Property function to get its value. The code sample below illustrates how you implement these steps.
MQStatus status; MQPropertiesHandle headersHandle = MQ_INVALID_HANDLE; MQBool redelivered; ConstMQString my_msgtype; status = (MQGetMessageHeaders(messageHandle, &headersHandle)); status = (MQGetBoolProperty(headersHandle, MQ_REDELIVERED_HEADER_PROPERTY, &redelivered)); status = MQGetStringProperty(headersHandle, MQ_MESSAGE_TYPE_HEADER_TYPE_PROPERTY, &my_msgtype); |