2

有没有办法编写 PCF 程序来获取处于“运行”状态的集群发送方/接收方通道的通道状态?
我有这样的东西,它只给我一个频道的频道状态!

 // send the request and collect the responses 
    String checkStatus="";
    String channelName ="";
 // build a request 
    request = new PCFMessage(CMQCFC.MQCMD_INQUIRE_CHANNEL_STATUS); 
 // add a parameter designating the name of the channel for which status is requested 
    request.addParameter(CMQCFC.MQCACH_CHANNEL_NAME, "TO.*"); 
 // add a parameter designating the instance type (current) desired 
    request.addParameter(CMQCFC.MQIACH_CHANNEL_INSTANCE_TYPE, CMQC.MQOT_CURRENT_CHANNEL); 

    responses = agent.send(request); 
    for (int j = 0; j < responses.length; j++) { 
         //  get the channel name and trim the spaces 
        String temp ="";
        temp = responses[j].getStringParameterValue(CMQCFC.MQCACH_CHANNEL_NAME); 
        channelName = temp.trim(); 

        int chlStatus = responses[j].getIntParameterValue(CMQCFC.MQIACH_CHANNEL_STATUS); 
        //System.out.println("channel status: " + chlStatus); 
        String[] chStatusText = { 
            "", "MQCHS_BINDING", "MQCHS_STARTING", "MQCHS_RUNNING", 
                "MQCHS_STOPPING", "MQCHS_RETRYING", "MQCHS_STOPPED", 
                "MQCHS_REQUESTING", "MQCHS_PAUSED", 
                "", "", "", "", "MQCHS_INITIALIZING" 
        }; 
        checkStatus = chStatusText[chlStatus]; 
        //System.out.println("channel status: " + checkStatus); 
    } 
    System.out.println("chl: " + channelName + " STATUS: " + checkStatus  + ")"); 

上面的代码只给出了一个通道而不是所有通道的通道状态。这里有什么问题?

4

2 回答 2

3

代码的 PCF 部分看起来不错,但打印出来的结果是错误的代码。

responses = agent.send(request); 
for (int j = 0; j < responses.length; j++) { 
    :
    :
    checkStatus = chStatusText[chlStatus];
} 
System.out.println("chl: " + channelName + " STATUS: " + checkStatus  + ")"); 

您有一个 for 循环围绕所有响应,但随后println位于 for 循环之外,因此仅打印出最终响应的结果。

于 2016-04-27T21:09:08.713 回答
1

去获取我名为MQ Channel Monitor的开源项目。下载源代码并查看“PCFChlStatus.java”文件。有一种称为 getMCAStatus() 的方法,基本上就是您所追求的。

于 2016-04-27T21:02:45.620 回答