Author |
Message
|
bhanu2032 |
Posted: Tue Mar 17, 2015 5:53 am Post subject: Java PCF MQCMD_INQUIRE_CLUSTER_Q_MGR Attributes |
|
|
Newbie
Joined: 17 Mar 2015 Posts: 6
|
I'm trying to inquire the cluster queue manager attributes, I have tried several ways to get the Queue Managers names in Cluster
But unable to get the results
Here is the snippet.I have tried several ways like below.
PCFMessageAgent agent = new PCFMessageAgent("IB9QMGR");//queue manager name in cluster
PCFMessage pcfCmd = new PCFMessage(MQConstants.MQCMD_INQUIRE_CLUSTER_Q_MGR);
// pcfCmd.addParameter(MQConstants.MQCA_Q_MGR_NAME, "*");
pcfCmd.addParameter(MQConstants.MQCA_CLUSTER_Q_MGR_NAME, "*");
//pcfCmd.addParameter(MQConstants.MQQMF_REPOSITORY_Q_MGR, "*");
//pcfCmd.addParameter(MQConstants.MQCA_CLUSTER_NAME, "test");
PCFMessage[] pcfResponse =agent.send(pcfCmd);
System.out.println("|Index| QMANAGER |");
String[] names = (String[]) pcfResponse[0].getParameterValue(MQConstants.MQCA_Q_MGR_NAME);
//String[] names = (String[]) pcfResponse[0].getParameterValue(MQConstants.MQQMF_REPOSITORY_Q_MGR);
// String[] names = (String[]) pcfResponse[0].getParameterValue(MQConstants.MQCA_CLUSTER_Q_MGR_NAME);
System.out.print(pcfResponse.toString());
for (int i = 0; i < names.length; i++)
{
System.out.println ("QueueManager: " + names [i]);
}
If you have any ideas/sample code please let me know
Error:-
For the above code i am getting Null Pointer Exception as the results are not being returned to the names array. |
|
Back to top |
|
 |
hughson |
Posted: Tue Mar 17, 2015 5:56 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
What is the PCF reason code returned to you by the command server?
Cheers
Morag
Last edited by hughson on Tue Mar 17, 2015 6:37 am; edited 1 time in total |
|
Back to top |
|
 |
bhanu2032 |
Posted: Tue Mar 17, 2015 6:34 am Post subject: Java PCF MQCMD_INQUIRE_CLUSTER_Q_MGR Attributes |
|
|
Newbie
Joined: 17 Mar 2015 Posts: 6
|
@f30bd1d6
This was the response code i think its an object that is returned |
|
Back to top |
|
 |
hughson |
Posted: Tue Mar 17, 2015 6:36 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
I was hoping for an integer in the 2000-4000 range. That looks like an address, can you check again please.
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
bhanu2032 |
Posted: Tue Mar 17, 2015 6:45 am Post subject: Java PCF MQCMD_INQUIRE_CLUSTER_Q_MGR |
|
|
Newbie
Joined: 17 Mar 2015 Posts: 6
|
When i have changed the code like
PCFMessageAgent agent = new PCFMessageAgent("IB9QMGR");
PCFMessage pcfCmd = new PCFMessage(MQConstants.MQCMD_INQUIRE_CLUSTER_Q_MGR);
pcfCmd.addParameter(MQConstants.MQCA_Q_MGR_NAME, "*");
//pcfCmd.addParameter(MQConstants.MQCA_CLUSTER_Q_MGR_NAME, "*");
//pcfCmd.addParameter(MQConstants.MQQMF_REPOSITORY_Q_MGR, "*");
//pcfCmd.addParameter(MQConstants.MQCA_CLUSTER_NAME, "test");
PCFMessage[] pcfResponse =agent.send(pcfCmd);
System.out.println("|Index| QMANAGER |");
System.out.println(pcfResponse.toString());
//MQConstants.MQQMF_REPOSITORY_Q_MGR
//String[] names = (String[]) pcfResponse[0].getParameterValue(MQConstants.MQCA_Q_MGR_NAME);
//String[] names = (String[]) pcfResponse[0].getParameterValue(MQConstants.MQQMF_REPOSITORY_Q_MGR);
String[] names = (String[]) pcfResponse[0].getParameterValue(MQConstants.MQCA_CLUSTER_Q_MGR_NAME);
System.out.print(pcfResponse.toString());
for (int i = 0; i < names.length; i++)
{
System.out.println ("QueueManager: " + names [i]);
}
Then i am getting result as
Error:-
MQJE001: Completion Code '2', Reason '3015'.
Exception in thread "main" com.ibm.mq.headers.pcf.PCFException: MQJE001: Completion Code '2', Reason '3015'.
at com.ibm.mq.headers.pcf.PCFMessageAgent.send(PCFMessageAgent.java:246)
at ClusQmgr.main(ClusQmgr.java:27) |
|
Back to top |
|
 |
hughson |
Posted: Tue Mar 17, 2015 7:03 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
That's the one!
So now you can look up what 3015 means.
It means MQRCCF_CFST_PARM_ID_ERROR.
Most of your code is commented out and it seems you only have one parm, which is a CFST (i.e. string) parm.
If you look at the reference page for the Inquire Cluster Queue Manager PCF command, you'll see two things:-- There is a required parameter, MQCA_CLUSTER_Q_MGR_NAME, which you do not have (it's one of your commented out lines).
- The parameter you are using, MQCA_Q_MGR_NAME, is not one of those you can use with this command.
So, you need to change the parm you are providing to MQCA_CLUSTER_Q_MGR_NAME.
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
bhanu2032 |
Posted: Tue Mar 17, 2015 7:13 am Post subject: Java PCF MQCMD_INQUIRE_CLUSTER_Q_MGR |
|
|
Newbie
Joined: 17 Mar 2015 Posts: 6
|
I have just now changed the code as you have asked for the response code.
But the code which i was using was not returning any response code
Its just returning address only.
So now here is the code
PCFMessageAgent agent = new PCFMessageAgent("IB9QMGR");
PCFMessage pcfCmd = new PCFMessage(MQConstants.MQCMD_INQUIRE_CLUSTER_Q_MGR);
pcfCmd.addParameter(MQConstants.MQCA_CLUSTER_Q_MGR_NAME, "*");
PCFMessage[] pcfResponse =agent.send(pcfCmd);
System.out.println("|Index| QMANAGER |");
String[] names = (String[]) pcfResponse[0].getParameterValue(MQConstants.MQCA_Q_MGR_NAME);
System.out.print(pcfResponse.toString());
for (int i = 0; i < names.length; i++)
{
System.out.println ("QueueManager: " + names [i]);
}
This is the Error Raised:-
|Index| QMANAGER |
Exception in thread "main" java.lang.NullPointerException
at ClusQmgr.main(ClusQmgr.java:24)
[Lcom.ibm.mq.headers.pcf.PCFMessage;@fc0f9f0a |
|
Back to top |
|
 |
hughson |
Posted: Tue Mar 17, 2015 7:16 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
You can't assume that the array you are trying to read is populated with anything if you don't check the PCF reason code first. The code you put in to display it when I asked should have a permanent place in your application and you should only proceed to read response structures if the return code is zero.
So, at the risk of repeating myself, what is your PCF return code now?
Also, please check on the page I referenced for you earlier that the constant you are building the response array with is even returned on this command! I don't see MQCA_Q_MGR_NAME listed as a possible returned value.
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
bhanu2032 |
Posted: Tue Mar 17, 2015 9:00 am Post subject: Java PCF MQCMD_INQUIRE_CLUSTER_Q_MGR |
|
|
Newbie
Joined: 17 Mar 2015 Posts: 6
|
Ok I am looking in to that by debugging.
If possible do you have any sample code for getting the queue Managers in a cluster
My scenario is to get the queue Manager names from the cluster.
But we cannot directly get the queue managers from the cluster.
At console:- After connecting to any queue manager in cluster using runmqsc we can get the queue managers in cluster by using DISPLAY CLUSQMGR
For this same purpose we have MQCMD_INQUIRE_CLUSTER_Q_MGR in pcf
So i think now you have understood my requirement.
If possible please give me some sample code
Thank you So much for your immediate response.  |
|
Back to top |
|
 |
hughson |
Posted: Tue Mar 17, 2015 9:07 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
Please change your code as per my previous response. You have a line like this:-
Code: |
String[] names = (String[]) pcfResponse[0].getParameterValue(MQConstants.MQCA_Q_MGR_NAME); |
which is attempting to retrieve a parameter from the response message that won't be returned to you by the command. Please review the link I provided you in an earlier answer and change the constant MQCA_Q_MGR_NAME to be one that is actually returned by the command. I expect what you wanted is the same constant that you changed in the earlier line of code to get rid of the 3015 error.
Please also reinsert the line you added that only proceeds to work with the pcfResponse if the return code is zero. This will stand you in good stead going forward.
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
bhanu2032 |
Posted: Wed Mar 18, 2015 4:30 am Post subject: Java PCF MQCMD_INQUIRE_CLUSTER_Q_MGR |
|
|
Newbie
Joined: 17 Mar 2015 Posts: 6
|
I have made several changes to the code as for your suggestions.
Now I am able to get the Reason code as zero.
But still the array called names being used was getting the value as null.
code:-
PCFMessageAgent agent = new PCFMessageAgent("MQUSEREXITS");
PCFMessage pcfCmd = new PCFMessage(CMQCFC.MQCMD_INQUIRE_CLUSTER_Q_MGR);
pcfCmd.addParameter(CMQC.MQCA_CLUSTER_Q_MGR_NAME,"*");
PCFMessage[] pcfResponse =agent.send(pcfCmd);
System.out.println("|Index|QueueManager |ReasonCode"+pcfResponse[0].getReason());
String[] names = (String[]) pcfResponse[0].getParameterValue(CMQC.MQCA_Q_MGR_NAME);
for (int i = 0; i < names.length; i++)
{
System.out.println ("QueueManagers: " + names [i]);
}
}
am I right in using the CMQC.MQCA_Q_MGR_NAME parameter to get the list of all queue managers in a cluster to be stored in an array  |
|
Back to top |
|
 |
hughson |
Posted: Wed Mar 18, 2015 5:55 am Post subject: Re: Java PCF MQCMD_INQUIRE_CLUSTER_Q_MGR |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
bhanu2032 wrote: |
am I right in using the CMQC.MQCA_Q_MGR_NAME parameter to get the list of all queue managers in a cluster to be stored in an array  |
No! My last three replies have been trying to get you to change that! Please go and read them. _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
vsathyan |
Posted: Tue Jul 07, 2015 10:51 am Post subject: |
|
|
Centurion
Joined: 10 Mar 2014 Posts: 121
|
This worked in C#. Try the same in Java. It should work..
Code: |
public ArrayList GetClusterQueueManagerNames(MQQueueManager qmgr)
{
try
{
ArrayList clusQmgrNames = new ArrayList();
if (qmgr != null)
{
PCFMessageAgent agent = new PCFMessageAgent(qmgr);
PCFMessage request = new PCFMessage(MQC.MQCMD_INQUIRE_CLUSTER_Q_MGR);
request.AddParameter(MQC.MQCA_CLUSTER_Q_MGR_NAME, "*");
PCFMessage[] responses = agent.Send(request);
if (responses != null && responses.Length > 0)
{
if (responses[0].GetCompCode() == MQC.MQCC_OK)
{
foreach (PCFMessage response in responses)
{
string clusQmgrName = response.GetStringParameterValue(MQC.MQCA_CLUSTER_Q_MGR_NAME).ToString().Trim();
if (clusQmgrName != "")
{
clusQmgrNames.Add(clusQmgrName);
}
}
}
}
}
return clusQmgrNames;
}
catch (MQException mqex)
{
//catch MQException here
return null;
}
|
 _________________ Custom WebSphere MQ Tools Development C# & Java
WebSphere MQ Solution Architect Since 2011
WebSphere MQ Admin Since 2004 |
|
Back to top |
|
 |
|