Inquiry

It is possible to inquire upon the properties of queue. This is achieved by using the inquire action. The details that are required are set. If using an administration message, the administration reply message contains a fields object with the required information. When using the API, a structure will be filled out with the requested information.

Administration message

There are two ways of inquiring on a queue, inquire or inquireAll. InquireAll returns a fields object in the admin reply message.

/* Create an empty queue admin message and parameters field*/
 MQeQueueAdminMsg msg = new MQeQueueAdminMsg();
 
/*Prime the message with who to reply to and a unique identifier      
 * Set the admin action to get all characteristics of queue manager.
 */
msg.inquireAll(new MQeFields());
 
/* get message back from the admin reply queue to match */
/* and retrieve the results from the reply message */

The fields object that is returned in the administration reply message is populated with all of the properties of the queue. To get access to a specific value, use the field labels as shown in the property table above. For example, to get at the queue description, assuming respMsg is the administration reply message:

// all on one line
String description = respMsg.getOutputFields().
		getAscii(com.ibm.mqe.administration.Queue_Description)

You can request only certain properties of a queue. If, for example, only the description is required, use the following example.

Figure 29. Inquiring on a queue in Java

	MQeFields requestedProperties = new MQeFields();
	requestedProperties.putAscii(Queue_Description);
	msg.inquire(requestedProperties)
	
	/* Retrieve the administration reply */ 
	/* message from the relevant queue */
	/* Then retrieve the returned MQeFields */
	/* object from this message */
	MQeFields  outputFields = respMsg.getOutputFields();

Output fields now contains the field Queue_Description only.

C API

The API takes the same parameter structure that other APIs, such as create, take. To specify the required elements, set the opFlags accordingly. To get, for example, the queue maximum depth, expiry, and description, set the opflags as follows:

Figure 30. Inquiring on a queue in C

MQeLocalQParms params = LOCAL_Q_INIT_VAL;
 
params.opflags = QUEUE_MAX_Q_SIZE_OP | QUEUE_EXPIRY_OP | QUEUE_DESC_OP;
 
rc = mqeAdministrator_LocalQueue_inquire(hAdministrator,
                                         &exceptBlk,
                                         hQueueName,
                                         hQueueMgrName,
                                         &params);
if (MQERETURN_OK == rc) {
   MQEINT64 queueExpiry = params.queueExpiry;
   MQEINT32 queueMaxSize = params.queueMaxQSize;
   MQeStringHndl queueDescription = params. hDescription;
}


© IBM Corporation 2002. All Rights Reserved