Filtering and querying data items

When using the MQAI to inquire about the attributes of IBM MQ objects, we can control the data that is returned to your program in two ways.

  • We can filter the data that is returned using the mqAddInteger and mqAddString calls. This approach lets you specify a Selector and ItemValue pair, for example:
    mqAddInteger(inputbag, MQIA_Q_TYPE, MQQT_LOCAL)
    
    This example specifies that the queue type (Selector) must be local (ItemValue) and this specification must match the attributes of the object (in this case, a queue) about which you are inquiring.

    Other attributes that can be filtered correspond to the PCF Inquire* commands that can be found in Introduction to IBM MQ Programmable Command Formats. For example, to inquire about the attributes of a channel, see the Inquire Channel command in this product documentation. The "Required parameters" and "Optional parameters" of the Inquire Channel command identify the selectors that we can use for filtering.

  • We can query particular attributes of an object using the mqAddInquiry call. This specifies the selector in which you are interested. If we do not specify the selector, all attributes of the object are returned.
Here is an example of filtering and querying the attributes of a queue:
/* Request information about all queues */
mqAddString(adminbag, MQCA_Q_NAME, "*")

/* Filter attributes so that local queues only are returned */
mqAddInteger(adminbag, MQIA_Q_TYPE, MQQT_LOCAL)

/* Query the names and current depths of the local queues */
mqAddInquiry(adminbag, MQCA_Q_NAME)
mqAddInquiry(adminbag, MQIA_CURRENT_Q_DEPTH)

/* Send inquiry to the command server and wait for reply */
mqExecute(MQCMD_INQUIRE_Q, ...)