Sun GlassFish Message Queue 4.4 Developer's Guide for C Clients

Getting Message Properties

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:

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 

MQPropertiesKeyIterationStart

Starts the iteration process through the specified properties handle. 

MQPropertiesKeyIterationHasNext

Returns MQ_TRUE if there are additional property keys left in the iteration.

MQPropertiesKeyIterationGetNext

Passes back the address of the next property key in the referenced property handle. 

MQGetPropertyType

Gets the type of the specified property. 

MQGetBoolProperty

Gets the value of the specified MQBool type property.

MQGetStringProperty

Gets the value of the specified MQString type property.

MQGetInt8Property

Gets the value of the specified MQInt8 type property.

MQGetInt16Property

Gets the value of the specified MQInt16 type property.

MQGetInt32Property

Gets the value of the specified MQInt32 type property.

MQGetInt64Property

Gets the value of the specified MQInt64 type property.

MQGetFloat32Property

Gets the value of the specified MQFloat32 type property.

MQGetFloat64Property

Gets the value of the specified MQFloat64 type property.

ProcedureTo Iterate Through a Properties Handle

  1. Start the process by calling the MQPropertiesKeyIterationStart() function.

  2. Loop using the MQPropertiesKeyIterationHasNext() function.

  3. Extract the name of each property key by calling the MQPropertiesKeyIterationGetNext() function.

  4. Determine the type of the property value for a given key by calling the MQGetPropertyType() function.

  5. 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);