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:

  • Connects to a queue manager

  • Opens a IBM MQ queue

  • PUTs a message to the queue

  • Closes the queue

  • Disconnects from the queue manager

QMQNB002

Puts a message to a queue on an z/OS queue manager using put1

The code is divided into three tasks:

  • Connects to a queue manager

  • PUT1s a message to a queue

  • Disconnects from the queue manager

QMQNB003

Browses a local queue defined to an z/OS queue manager

The code is divided into five tasks:

  • Connects to a queue manager

  • Opens a IBM MQ queue

  • Gets a message for browse from an opened queue

  • Closes the queue

  • Disconnects from the queue manager

QMQNB004

Puts a message to two different queues using syncpoint

The code is divided into nine tasks:

  • Connects to a queue manager

  • Opens the first queue

  • puts a message to the first queue and begins syncpoint processing

  • Closes that queue

  • Opens the second queue

  • puts a message to the second queue using the same syncpoint

  • Closes the second queue

  • Commits all work since last syncpoint

  • Disconnects from the queue manager

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:

  • Connects to the queue manager

  • Opens a queue

  • GETs 10 messages from the queue and displays each of them in the BBI Journal

  • Closes the queue

  • Disconnects the queue manager

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:

  • Displays non-zero return codes

  • Displays MQ messages

  • Returns to caller

In the following example, QMQNB001 PUTs a message to a queue on an z/OS queue manager:

/*-------------------------------REXX--------------------------------*/ 
/* 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                            */ 
/*-------------------------------------------------------------------*/
/* This statement causes a connection to the Queue Manager.          */ 
/* 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)'

Was this page helpful? Yes No Submitting... Thank you

Comments