The purpose of WebSphere® MQ programmable command format (PCF) commands is to allow administration tasks to be programmed into an administration program. In this way, from a program we can manipulate queue manager objects (queues, process definitions, namelists, channels, client connection channels, listeners, services, and authentication information objects), and even manipulate the queue managers themselves.
PCF commands cover the same range of functions provided by MQSC commands. We can write a program to issue PCF commands to any queue manager.
Each PCF command is a data structure that is embedded in the application data part of a WebSphere MQ message. Each command is sent to the target queue manager using the MQI function MQPUT in the same way as any other message. Providing the command server is running on the queue manager receiving the message, the command server interprets it as a command message and runs the command. To get the replies, the application issues an MQGET call and the reply data is returned in another data structure. The application can then process the reply and act accordingly.
Sample Java code for creating local queues :
Imports are :
import com.ibm.mq.MQC;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQQueueManager;
import com.ibm.mq.constants.CMQC;
import com.ibm.mq.constants.CMQCFC;
import com.ibm.mq.headers.pcf.MQCFIN;
import com.ibm.mq.headers.pcf.MQCFST;
import com.ibm.mq.headers.pcf.PCFAgent;
import com.ibm.mq.headers.pcf.PCFParameter;
import com.ibm.mq.pcf.MQCFH;
import com.ibm.mq.pcf.MQCFSL;
private static void createQueues(String[] queues)throws Exception {
MQQueueManager qMgr;
qMgr = new MQQueueManager("QM");
PCFAgent agent = new PCFAgent (qMgr);
MQMessage [] responses;
int queueCounter =0;
for(;queueCounter<queues.length;queueCounter++)
{
PCFParameter [] parameters =
{
new MQCFST (CMQC.MQCA_Q_NAME, queues[queueCounter]),
new MQCFIN (CMQC.MQIA_Q_TYPE, MQC.MQQT_LOCAL)
};
MQCFH cfh;
responses = agent.send (CMQCFC.MQCMD_CREATE_Q, parameters);
cfh = new MQCFH (responses [0]);
if(cfh.reason==4001)
System.out.println("Queue Name : "+queues[queueCounter] +" is already present");
else if(cfh.reason==0)
System.out.println("Queue Name : "+queues[queueCounter] +" is created");
}
}
Sample Java code for displaying all the local queues in queue manager:
private static void getQueueNames() throws Exception {
MQQueueManager qMgr;
qMgr = new MQQueueManager("QM");
PCFAgent agent = new PCFAgent (qMgr);
MQMessage [] responses;
PCFParameter [] parameters =
{
new MQCFST (CMQC.MQCA_Q_NAME, "*"),
new MQCFIN (CMQC.MQIA_Q_TYPE, MQC.MQQT_LOCAL)
};
MQCFH cfh;
MQCFSL cfsl;
responses = agent.send (CMQCFC.MQCMD_INQUIRE_Q_NAMES, parameters);
cfh = new MQCFH (responses [0]);
if (cfh.reason == 0)
{
cfsl = new MQCFSL (responses [0]);
for (int i = 0; i < cfsl.strings.length; i++)
{
System.out.println ("Queue: " + cfsl.strings [i]);
}
}
}
Jars required :
com.ibm.mq.headers.jar
com.ibm.mq.jar
com.ibm.mq.jmqi.jar
com.ibm.mq.pcf.jar
Jars required :
com.ibm.mq.headers.jar
com.ibm.mq.jar
com.ibm.mq.jmqi.jar
com.ibm.mq.pcf.jar
For more info : http://publibfp.dhe.ibm.com/epubs/pdf/csqzac05.pdf
This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this.
ReplyDeleteAre you aware of any other websites on this
IBM-MQ WEBSPHERE Online training
.
Hi Harish,
ReplyDeleteThank you for the useful information.
I am facing a issue, when I try to import 'com.ibm.mq.headers.pcf.PCFAgent' an error shows up that PCFAgent class is not found. I tried downloading jars but no luck. None of them have got PCFAgent class.
Could you please help me.
Thank you in advance
Yeah , it is a good post and valuable.
ReplyDeleteOne thing I like to add here rather to download the jars(given 4 jar Names) take it from the MQ installation lib directory.
It will help you jar version dependency problem, which I was experienced.
Thanks for ur feedback..
DeleteThanks for ur feedback..
DeleteNice site for ORACLE, Good Information provided my Mate on OBIEE Online Training
ReplyDeletethe great support you have provided.
ReplyDeleteFull Stack Training in Chennai | Certification | Online Training Course | Full Stack Training in Bangalore | Certification | Online Training Course | Full Stack Training in Hyderabad | Certification | Online Training Course | Full Stack Training in Pune | Certification | Online Training Course | Full Stack Training | Certification | Full Stack Online Training Course
I have read your blog its very attractive and impressive
ReplyDeleteWebsphere mq Training in Bangalore