How to Open a Queue in MQseries with MQOPEN

In MQSeries opening the Queue is the first step. This sample program tell you the list of options available for MQOPEN:

-Open a queue and specify that all messages put to that queue must be directed to the 
same instance of it.
-Open a queue to allow you to put messages on it
-Open a queue to allow you to browse messages on it
-Open a queue to allow you to remove messages from it
-Open an object to allow you to inquire about and set its attributes 
(but you can set the attributes of queues only)
-Open a topic or topic string to publish messages to it
-Associate context information with a message
-Nominate an alternative user identifier to be used for security checks
-Control the call if the queue manager is in a quiescing state
 * -------------------------------------------------------*
 WORKING-STORAGE SECTION.
 * -------------------------------------------------------*
 *
 *    W02 - Queues processed in this program
 *
 01  W02-MODEL-QNAME        PIC X(48) VALUE
 'CSQ4SAMP.B1.MODEL                          '.
 01  W02-NAME-PREFIX        PIC X(48) VALUE
 'CSQ4SAMP.B1.*                              '.
 01  W02-TEMPORARY-Q         PIC X(48).
 *
 *    W03 - MQM API fields
 *
 01  W03-HCONN       PIC S9(9) BINARY VALUE ZERO.
 01  W03-OPTIONS     PIC S9(9) BINARY.
 01  W03-HOBJ        PIC S9(9) BINARY.
 01  W03-COMPCODE    PIC S9(9) BINARY.
 01  W03-REASON      PIC S9(9) BINARY.
 *
 *    API control blocks
 *
 01  MQM-OBJECT-DESCRIPTOR.
 COPY CMQODV.
 *
 *    CMQV contains constants (for setting or testing
 *    field values) and return codes (for testing the
 *    result of a call)
 *
 01  MQM-CONSTANTS.
 COPY CMQV SUPPRESS.
 * -------------------------------------------------------*
 PROCEDURE DIVISION.
 * -------------------------------------------------------*
 ⋮
 * -------------------------------------------------------*
 OPEN-TEMP-RESPONSE-QUEUE SECTION.
 * -------------------------------------------------------*
 *
 *  This section creates a temporary dynamic queue
 *  using a model queue
 *
 * -------------------------------------------------------*
 *
 * Change three fields in the Object Descriptor (MQOD)
 * control block.  (MQODV initializes the other fields)
 *
 MOVE MQOT-Q           TO MQOD-OBJECTTYPE.
 MOVE W02-MODEL-QNAME  TO MQOD-OBJECTNAME.
 MOVE W02-NAME-PREFIX  TO MQOD-DYNAMICQNAME.
 *
 COMPUTE W03-OPTIONS = MQOO-INPUT-EXCLUSIVE.
 *
 CALL 'MQOPEN' USING W03-HCONN
 MQOD
 W03-OPTIONS
 W03-HOBJ-MODEL
 W03-COMPCODE
 W03-REASON.
 *
 IF W03-COMPCODE NOT = MQCC-OK
 MOVE 'MQOPEN'      TO M01-MSG4-OPERATION
 MOVE W03-COMPCODE  TO M01-MSG4-COMPCODE
 MOVE W03-REASON    TO M01-MSG4-REASON
 MOVE M01-MESSAGE-4 TO M00-MESSAGE
 ELSE
 MOVE MQOD-OBJECTNAME TO W02-TEMPORARY-Q
 END-IF.
 *
 OPEN-TEMP-RESPONSE-QUEUE-EXIT.
 *
 *    Return to performing section.
 *
 EXIT.
 EJECT
 *
Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.