Tuesday, 15 April 2014

PCF Commands

 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 you can create queues, process definitions, channels, and namelists, and change queue managers, from a program.


     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. The command server on the queue manager receiving the message 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.

Briefly, these are some of the things the application programmer must specify to create a PCF command message:

Message descriptor

This is a standard IBM MQ message descriptor, in which:
·         Message type ( MsgType ) is MQMT_REQUEST.
·         Message format ( Format ) is MQFMT_ADMIN.
Application data

Contains the PCF message including the PCF header, in which:
·         The PCF message type ( Type ) specifies MQCFT_COMMAND.
·         The command identifier specifies the command, for example, Change Queue (MQCMD_CHANGE_Q).

Escape PCFs are PCF commands that contain MQSC commands within the message text. You can use PCFs to send commands to a remote queue manager.

Sample Java code to get cluster QueueManager Details

import java.io.IOException;
import com.ibm.mq.constants.CMQC;
import com.ibm.mq.constants.CMQCFC;
import com.ibm.mq.constants.MQConstants;
import com.ibm.mq.headers.pcf.PCFException;
import com.ibm.mq.headers.pcf.PCFMessage;
import com.ibm.mq.headers.pcf.PCFMessageAgent;
import com.ibm.mq.headers.MQDataException;


public class ClusQmgr {
     
public static void main (String [] args) throws MQDataException,PCFException, MQDataException,IOException
    {
//intializes a new PCFMessageAgent with a binding connection to a QueueManager
PCFMessageAgent agent = new PCFMessageAgent("EB310000");

//initializes PCFMessage as a PCF request
PCFMessage pcfCmd = new PCFMessage(CMQCFC.MQCMD_INQUIRE_CLUSTER_Q_MGR);

//add PCF parameters to PCFMessage
 pcfCmd.addParameter(CMQC.MQCA_CLUSTER_Q_MGR_NAME,"*");

//sends a PCF request to connect Queue Manager and return the responses
PCFMessage[] pcfResponse =agent.send(pcfCmd);
              
String ClustQmgr=" ";
String[] ConDetails;
String Hostname=" ";
String Port=" ";

System.out.println("*****QueueManager*******Host*********Port**********");

for (PCFMessage pcfMessage : pcfResponse)
{

//get cluster Queue Manager Name      ClustQmgr=pcfMessage.getParameterValue(CMQC.MQCA_CLUSTER_Q_MGR_NAME).toString().trim();

//get connection Details      ConDetails=(pcfMessage.getParameterValue(MQConstants.MQCACH_CONNECTION_NAME).toString().trim()).split("\\(",2);

//get Host name
Hostname=ConDetails[0];

//get port name
Port=ConDetails[1].substring(0,ConDetails[1].length()-1 );
      System.out.println("*****"+ClustQmgr+"*******"+Hostname+"*********"+Port+"**********");
                 
            }
           
            }

No comments:

Post a Comment