MQI coding and utility EXECs
To help users write MQ Automation more quickly, MainView AutoOPERATOR for MQ provides sample code for the more common MainView AutoOPERATOR commands. These examples contain a shell consisting of all the pieces necessary to execute a IBM MQ request, such as putting a message to a queue or manipulating a IBM MQ resource. The example code can be copied or cut and pasted into your EXECs, where you can then modify the examples, or portions of the examples, to fit the needs for your particular request.
These examples are located in BBSAMP and are named QMQNB001 - QMQNB009.
Table 1 lists the nine examples and the actions that they perform.
Table 1. MQI code examples
Example name | Description |
---|---|
QMQNB001 | Puts a message to a queue on an z/OS queue manager The code is divided into five sections that each complete a specific task:
|
QMQNB002 | Puts a message to a queue on an z/OS queue manager using put1 The code is divided into three tasks:
|
QMQNB003 | Browses a local queue defined to an z/OS queue manager The code is divided into five tasks:
|
QMQNB004 | Puts a message to two different queues using syncpoint The code is divided into nine tasks:
|
QMQNB005 | Displays the status of a queue manager resource The code contains one task: displays the status of performance events for the queue manager |
QMQNB006 | Alters the status of a queue manager The code is contains one task: alters the QMGR to allow INHIBIT events for the queue manager |
QMQNB007 | Alters the status of a queue The code contains one task: alters a queue to allow Q_Depth_High monitoring and to set a threshold of 80% |
QMQNB008 | Using the GET command, GETs 10 messages for browse from a queue and writes the message text to the BBI Journal The code is divided into five tasks:
|
QMQNB009 | Contains a diagnostic procedure that can be copied into any EXEC that uses MainView AutoOPERATOR MQI or MainView AutoOPERATOR for MQ command facility The code is divided into three tasks:
|
In the following example, QMQNB001 PUTs a message to a queue on an z/OS queue manager:
/* QMQNB001 - */
/* This sample PUTs a message to a queue on an z/OS Queue Manager. */
/* Keyword parameters will be used to set the appropriate values for */
/* input to each call to the MQI. */
/* Change Activity: */
/* 09-29-2000: Updated for new interface */
/*-------------------------------------------------------------------*/
/* NAME = Queue Manager ID */
/*-------------------------------------------------------------------*/
'IMFEXEC MQI CONN NAME(mqid)'
/*-------------------------------------------------------------------*/
/* This statement opens a IBM MQ Queue. */
/* HOBJ = Queue name */
/* HCONN = connection handle (can be omitted, default is IMFHCONN) */
/* OOPTS = queue is opened for output */
/*-------------------------------------------------------------------*/
IMFMQI_OD_OBJECTNAME = qname
'IMFEXEC MQI OPEN HCONN(IMFHCONN) OOPTS(MQOO_OUTPUT)'
/*-------------------------------------------------------------------*/
/* This statement PUTs a message to a previously opened queue. */
/* HCONN = connection handle (can be omitted, default is IMFHCONN) */
/* HOBJ = queue name, set by previous OPEN */
/* POPTS = PUT options */
/* BUFFLEN = length of variable containing application data */
/* BUFFER = name of variable that contains application data */
/*-------------------------------------------------------------------*/
'IMFEXEC MQI PUT HCONN(IMFHCONN) HOBJ(IMFHOBJ) POPTS(MQPMO_NO_SYNCPOINT)',
'BUFFLEN('LENGTH(message)') BUFFER(message)'
/*-------------------------------------------------------------------*/
/* This statement closes a IBM MQ Queue. */
/* HOBJ = Queue name */
/* HCONN = connection handle (can be omitted, default is IMFHCONN) */
/* COPTS = None is specified for pre-defined queues */
/*-------------------------------------------------------------------*/
'IMFEXEC MQI CLOSE COPTS(MQCO_NONE) HOBJ(IMFHOBJ)'
/*-------------------------------------------------------------------*/
/* This statement causes a disconnection from the Queue Manager. */
/* HCONN = Connection handle set during previous connect */
/*-------------------------------------------------------------------*/
'IMFEXEC MQI DISC HCONN(IMFHCONN)'