通过来自 Java 的 PCF 请求获取连接到 IBM MQ 队列的消费者的 ip

Get ip of consumers who connected to IBM MQ queue by PCF request from Java

我知道 MQExplorer GUI 可以显示谁通过某个通道连接到某个队列以及有关此连接的其他信息,但我在 PCF 中没有找到任何可以做到这一点的 Java。

提前感谢您提供命令和示例(如果存在)!

您在 MQ 资源管理器中看到的是 MQSC 命令:

DISPLAY QSTATUS(<QName>) TYPE(HANDLE)

因此,您需要查找等效的 PCF 命令。

这显示示例代码段显示如何检索 conname

// Create the PCF message type for the inquire.
PCFMessage pcfCmd = new PCFMessage(MQConstants.MQCMD_INQUIRE_Q_STATUS);
// Add queue name
pcfCmd.addParameter(MQConstants.MQCA_Q_NAME, "MYQ");
// We want Q HANDLE attributes
pcfCmd.addParameter(MQConstants.MQIACF_Q_STATUS_TYPE, MQConstants.MQIACF_Q_HANDLE);
// We want to retrieve only the connection name
pcfCmd.addParameter(MQConstants.MQIACF_Q_STATUS_ATTRS, MQConstants.MQCACH_CONNECTION_NAME);
// Execute the command. The returned object is an array of PCF messages.
PCFMessage[] pcfResponse = pcfCM.agent.send(pcfCmd);

try{
    for(int i = 0; i < pcfResponse.length;i++){
        String name = (String) pcfResponse[i].getParameterValue(MQConstants.MQCACH_CONNECTION_NAME);
        System.out.println("Connection Name: " + name);         
        }
    }catch(Exception ex) {
    System.out.print(ex);
}

您可以根据需要修改代码段。希望对你有帮助。