Get the IP addresses of consumers who connected to the IBM MQ queue at the PCF request from Java

I know that the MQExplorer GUI can show who is connected to a queue by some channel and other information about this connection, but I did not find anything in PCF to do this with Java.

Thanks in advance for the commands and examples, if they exist!

+4
source share
2 answers

In this example, a sample fragment shows how to extract 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);
}

You can change the fragment to suit your needs. Hope this helps.

+3
source

What you see in MQ Explorer is the MQSC command:

DISPLAY QSTATUS(<QName>) TYPE(HANDLE)

So you need to find the equivalent PCF command.

0

Source: https://habr.com/ru/post/1614228/


All Articles