Inquire and Inquire all

In general, when inquiring on objects in WebSphere MQ Everyplace, it is possible to ask for particular parameters which are of interest using inquire, or just ask for all information using inquireAll.

Java or Administration message

In the Java interface, the presence of a field in the request message means that see the value the field that field failed in.

//inquire
 
//Request the value of description 
try {
   MQeAdminMsg msg = (MQeAdminMsg) new MQeQueueManagerAdminMsg();
//Prime admin message with targetQM name, reply to queue, and so on
//refer to chapter 2 for details
 
   parms = new MQeFields();
   parms.putUnicode(MQeQueueManagerAdminMsg.QMgr_Description, null);
 
   //set the name of the queue to inquire on
   msg.setName("ExampleQM");
 
   //Set the action required and its parameters into the message
   msg.inquire(parms);
//Put message to target admin queue (code not shown)
//refer to chapter two for details
} catch (Exception e) {
   System.err.println("Failure ! " + e.toString());
}
 
//inquire all
try {
     MQeAdminMsg msg = (MQeAdminMsg) new MQeQueueManagerAdminMsg();
 
     //set the name of the queue to inquire on
     msg.setName("ExampleQM");
 
     //Set the action required and its parameters into the message
     msg.inquireAll(new MQeFields());
 } catch (Exception e) {
     System.err.println("Failure ! " + e.toString());
 }

C API

The example below shows how to inquire on the list of queues. This is the most complex inquire that can be performed as a vector of structures is returned. All these structures must be freed as shown below. This queue info structure contains three strings and a MQeQueueType. The first two strings are the QueueQueueManager Name and the QueueName. Both of these strings must be freed. Then there is the Java Class Name - this is a constant string and therefore need not be freed. Finally there is a primitive MQeQueueType.

The Queue Info structure must be freed using the mqeMemory_free function. Please see the API Reference for more information on the mqeMemory function.

As well as information on queues, a vector of connection definitions can be returned. This should also be freed when it has been processed.

   MQeQueueManagerParms qmParms = QMGR_INIT_VAL;
   qmParms.opFlags |= QMGR_QUEUES_OP;
   rc = mqeAdministrator_QueueManager_inquire(hAdministrator,
                                             &exceptBlk,
                                             &qmParms);
   if (MQERETURN_OK == rc) {
      /* This has returned a Vector of information */
      /* blocks about the queues */
      MQeVectorHndl hListQueues = qmParms.hQueues;
      MQEINT32 numberQueues;
 
      rc = mqeVector_size(hListQueues,&exceptBlk,&numberQueues);
      if (MQERETURN_OK == rc) {
         MQEINT32 count;
         /* Loop round the array to get the information */
         /* about the queues */
         for (count=0;count<numberQueues;count++) {
            MQeQMgrQParms *pQueueInfo;
            rc = mqeVector_removeAt(hListQueues,
                                   &exceptBlk,
                                   &pQueueInfo,
                                    count);
            if (MQERETURN_OK == rc) {
               /* Queue QueueManager - FREE THIS STRING when done */
               MQeStringHndl hQMgrName = pQueueInfo->hOwnerQMgrName;
               /* QueueName - FREE THIS STRING*/
               MQeStringHndl hQueueName = pQueueInfo->hQMgrQName;
              /* A Constant String matching the Java Class Name */
              /* for this queue one of
               * MQE_QUEUE_LOCAL 
               * MQE_QUEUE_REMOTE 
               * MQE_QUEUE_ADMIN 
               * MQE_QUEUE_HOME_SERVER
               */
               MQeStringHndl hQueueClassName = pQueueInfo->hQueueType;
                   
               /* Will be set from MQeQueueType */
               MQeQueueType queueType = pQueueInfo->queueExactType;
 
               (void)mqeMemory_free(&exceptBlk,pQueueInfo);
 
            }
         }
      }
 
      /* the vector needs to be freed as well */
      mqeVector_free(hListQueues,&exceptBlk);
   }


© IBM Corporation 2002. All Rights Reserved