Search

Showing posts with label MQ. Show all posts
Showing posts with label MQ. Show all posts

Saturday, May 11, 2013

Writing MQ Batch Program and MQ JCL

How to start MQ batch program and MQ JCL?

Message Queuing is the bridge between agile world today. Today there are lot of variations in programming language. There is need of hour to make different systems integrate; talk with each other and to make this happen MQ series is one of the best option.

I have written couple of blogs on MQ efficiency  use etc.Today I will write MQ blog to understand how easy is to use MQ .

There are few steps which MQ batch program/JCL requires it:
MQ JCL
1. There is MQ load library which has in build objects which is needed by any MQ JCL and its is mostly named as from MQM*. in your mainframe system

2.  Check if the Queue Manager is passes to get connected to Queue Manager.Typically, all the mainframe system as SySplex. 

Now what is Sysplex? Sysplex is the word derived from system complex. This means generally the mainframe server are divided into one or more LPARs. LPARs are logical partition. This is done to use mainframe server efficiently. I will not go in this details now.

So coming back to point 2, due to Sysplex environment  each LPAR has its Queue Manager. And generally MQ admin group, mergers all the Queue Manager into one. So always confirm for Queue Manager from MQ admin. Due to this, it gives flexibility to MQ JCL to run against any Queue Manager available. Even if one is down, job will not fail it will run against next avaliable.

3.  Make sure you have correct Message Queue Names.

Logic is all the Message Queues are controlled by its Queue Manager. Queue Manager has couple of setting for Queues.

MQ Program

1. Check to include IBM MQ copy books. Its for MQ Manager Check, Message Queue Check, Parameters for both of them and return code checks. These copybooks are available on IBM site and they are pretty much standard for all the MQ programs.

2. Check that you have placed calls correctly. All the call along with parameters are available at IBM website.

Generally to read MQ it goes as:
a. Connect Queue Manager
b. Open Queue
c. Browse Message Queue - Keep it destructive read preferbly
d. Process the message
e. Close Queue
f. Disconnect Queue Manage 

Generally to write MQ it goes as:

Make sure you read the file from where you want to write message to Queue into working storage variable passed to Queue.
a. Connect Queue Manager
b. Open Queue
c. Write Message into Queue 
e. Close Queue
f. Disconnect Queue Manage 

Best practice is to check return code after every call.

3. Also check do MQDISCONNECT at the end. This helps to free resource immediately.


Sunday, January 20, 2013

CEDC Command to check MQconnection


CEDC Commands that can be used to check MQ connection 

If any user wants to know INITQ or any MQ manager or any other MQ parameter here is the command:

CEDC V MQ

It will give option as below. If you dont know give * for both the options and then press enter:

OBJECT CHARACTERISTICS
   CEDC View MQconn(         )
     MQconn         ==>      
*

     Group            ==>       *

It will display all the MQConn for all the sysplex region as below.

ENTER COMMANDS
NAME            TYPE            GROUP                       LAST CHANGE 
MQ1A            MQCONN      CICSAB1             25/04/11   11:11:11
MQ1A             MQCONN     CICSAB2   v        25/04/11   11:11:11   
      
Give View in front of group you want to view as I gave above in red and press enter.

Saturday, November 17, 2012

MQPUT Through JCL

JCL to LOAD the Data into MQ(Message Queue) channels from a sequential data set.

With CSQUTIL MQPUT can be done in batch.

//MQLOAD1  JOB (ABCDEFGH),'ABCDEFG',
//         MSGCLASS=T,SCHENV=DB2DBJB,
//         NOTIFY=&SYSUID,TIME=90
//*
//MKCMDS   EXEC PGM=CSQUTIL,PARM='Queue Manger Name'
//STEPLIB   DD DSN=MQM.M***.SCSQAUTH,DISP=SHR
//INFILE   DD DISP=SHR,DSN=TEST.RSS.XCI0500.STRGTEST.INPUT
//SYSPRINT DD SYSOUT=*
//CSQUOUT  DD SYSOUT=*
//SYSIN    DD *
LOAD QUEUE ( PK01) DDNAME(INFILE)
/*

JCL to Alter and Define Queues

Commands can be executed in JCL to alter/define MQ

Here I am altering INITQ for Local Queue PK01.

//PRODSTEP EXEC PGM=CSQUTIL,PARM='QueueManger Name'        <===== QMGR ?????
//SYSPRINT DD SYSOUT=* 
//STEPLIB DD DSN=MQM.SCSQLOAD,DISP=SHR 
//SYSIN DD *
COMMAND DDNAME(CMDGET)
/*
//CMDGET DD *
ALTER QLOCAL(PK01) INITQ(CICS1.INITQ)                                 

Friday, November 16, 2012

Delete Messages from Queue through JCL

Messages can be deleted from batch job

The below sample job deletes all the messages from a MQ. CSQUTIL is a utility program which enables to delete message from queue. Only the developer running this should have authority to access queue.

//EMPTY EXEC PGM=CSQUTIL,PARM='AB01'                    <---- Queue Manager
//STEPLIB DD DISP=SHR,DSN=MQM.SCSQANLE
//        DD DISP=SHR,DSN=MQM.SCSQAUTH
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
EMPTY QUEUE(MQTEST_Q)
/

Sunday, October 21, 2012

MQGET read in non-destructive way

MQGET OPTIONS to read Queue in Non Destructive Way

To delete from queue explicitly, developer needs to Read a queue, performing some other action and finally delete queue explicitly.

Steps:
During MQOPEN Call:
  •  Open Queue with MQOO_BROWSE option
  •   Check the message counter

Sunday, September 30, 2012

JCL TO ALTER or DEFINE Queues


Code snippets for defining or altering Message Queues through JCL

Here I am changing INITQ for Local Queue PK01.

//PRODSTEP EXEC PGM=CSQUTIL,PARM='QueueManger Name'              
//SYSPRINT DD SYSOUT=*                                                 
//STEPLIB DD DSN=MQM.SCSQLOAD,DISP=SHR                                
//SYSIN DD *      

Saturday, September 29, 2012

MQ Batch Triggering Process


We can set up MQ job through MQ triggering Process. Job will be automatically triggered through MQ. Whenever the message is written to MQ the job mentioned will get triggered (G170G170). Here are the steps to be followed.

SET UP MQ Trigger batch job