Author |
Message
|
kordi |
Posted: Sun May 18, 2014 6:26 am Post subject: Inquiring Channel results in RC 3047 |
|
|
Centurion
Joined: 28 May 2012 Posts: 146 Location: PL
|
Can someone advise me what am I doing wrong in following code that I get RC3047?
Code: |
import java.io.*;
import java.util.*;
import com.ibm.mq.*;
import com.ibm.mq.pcf.*;
public class mqCheck {
public static void main (String [] args) {
//PCFMessageAgent agent;
PCFMessage request;
PCFMessage[] responses;
PCFMessageAgent agent = new PCFMessageAgent();
request = new PCFMessage(CMQCFC.MQCMD_INQUIRE_CHANNEL);
request.addParameter (CMQCFC.MQCACH_CHANNEL_NAME, "*");
int[] attrs = {CMQCFC.MQCACH_DESC,CMQCFC.MQCACH_MCA_USER_ID,CMQCFC.MQCACH_CHANNEL_NAME,CMQCFC.MQIACH_CHANNEL_STATUS};
request.addParameter(CMQCFC.MQIACH_CHANNEL_INSTANCE_ATTRS, attrs);
try {
agent.connect("192.168.1.153", 1414, "MQADMIN.MO71.SVRCONN");
System.out.println("Połaczono");
}
catch (MQException ex) {
System.out.println("A WebSphere MQ Error occured : Completion Code " + ex.completionCode
+ " Reason Code " + ex.reasonCode);
ex.printStackTrace();
for (Throwable t = ex.getCause(); t != null; t = t.getCause()) {
System.out.println("... Caused by ");
t.printStackTrace();
}
}
try {
// send the request and collect the responses
responses = agent.send(request);
for (int i = 0; i < responses.length; i++) {
// get the channel name and trim the spaces
String temp = responses[i].getStringParameterValue(CMQCFC.MQCACH_CHANNEL_NAME);
String channelName = temp.trim();
// get the channel description and trim the spaces
temp = responses[i].getStringParameterValue(CMQCFC.MQCACH_DESC);
String description = temp.trim();
// get the channel MCAUSER
temp = responses[i].getStringParameterValue(CMQCFC.MQCACH_MCA_USER_ID);
String mcauser = temp.trim();
// get the channel status
int chlStatus = responses[i].getIntParameterValue(CMQCFC.MQIACH_CHANNEL_STATUS);
System.out.println("chl: " + channelName + " status: " + chlStatus + "MCAUSER(" + mcauser + ")" + "DESC(" + description + ")");
}
}
catch (PCFException pcfEx)
{
System.out.println("A WebSphere PCF Error occured : Completion Code " + pcfEx.completionCode
+ " Reason Code " + pcfEx.reasonCode);
pcfEx.printStackTrace();
} catch (MQException ex) {
System.out.println("A WebSphere MQ Error occured : Completion Code " + ex.completionCode
+ " Reason Code " + ex.reasonCode);
ex.printStackTrace();
for (Throwable t = ex.getCause(); t != null; t = t.getCause()) {
System.out.println("... Caused by ");
t.printStackTrace();
}
}
catch (Exception e)
{
e.printStackTrace();
}
try {
agent.disconnect();
System.out.println("Rozłaczono");
}
catch (MQException e) {
// We'll silently ignore it in this demonstration program
}
}
}
|
|
|
Back to top |
|
 |
hughson |
Posted: Tue May 20, 2014 7:17 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
3047 means MQRCCF_CFIL_PARM_ID_ERROR which means that you have an invalid parameter somewhere in a list. I suspect if you look at the rest of the information in the PCF response message that gave you that error it may also tell you the PARM_ID that was in ERROR.
However, without that information, and just guessing, I suspect you'll find that CMQCFC.MQIACH_CHANNEL_STATUS is not something you can inquire on CMQCFC.MQCMD_INQUIRE_CHANNEL. That parameter ID would be used on an MQCMND_INQUIRE_CHANNEL_STATUS command instead.
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
kordi |
Posted: Tue May 20, 2014 1:02 pm Post subject: |
|
|
Centurion
Joined: 28 May 2012 Posts: 146 Location: PL
|
Hi Morag,
Thanks for your reply, but I tried changing attrs list already leaving only CMQCFC.MQCACH_CHANNEL_NAME, but it didn't change anything, I still receive RC 3047 :/ |
|
Back to top |
|
 |
hughson |
Posted: Wed May 21, 2014 12:32 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
Better look at the complete PCF response then and see what the queue manager thinks is the bad PARM_ID. Can you provide a browse of the reply message content perhaps so we can look at it?
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
kordi |
Posted: Wed May 21, 2014 1:50 am Post subject: |
|
|
Centurion
Joined: 28 May 2012 Posts: 146 Location: PL
|
Oh, sure, where can I find this PCF reply message? |
|
Back to top |
|
 |
hughson |
Posted: Wed May 21, 2014 2:52 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
It's the message you are printing out the 3047 from.
You seem to have exception handling in there which you haven't showed us the output from - perhaps that contains what we need?
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
kordi |
Posted: Wed May 21, 2014 11:26 am Post subject: |
|
|
Centurion
Joined: 28 May 2012 Posts: 146 Location: PL
|
Here is my entire output generated by code above
MQJE001: Kod zakończenia: 2. Przyczyna: 3047.
A WebSphere PCF Error occured : Completion Code 2 Reason Code 3047
com.ibm.mq.pcf.PCFException: MQJE001: Kod zako˝czenia: 2. Przyczyna: 3047.
at com.ibm.mq.pcf.PCFMessageAgent.send(PCFMessageAgent.java:242)
at mqCheck.main(mqCheck.java:42)
Rozłaczono |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed May 21, 2014 3:06 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
Did you try our friend Mr. Google?
First off, you need a type, here is a simple setup:
Code: |
request.addParameter (CMQCFC.MQCACH_CHANNEL_NAME, "*");
request.addParameter (CMQCFC.MQIACH_CHANNEL_TYPE, CMQXC.MQCHT_ALL );
request.addParameter (CMQCFC.MQIACF_CHANNEL_ATTRS, new int [] {CMQCFC.MQIACF_ALL} );
|
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
kordi |
Posted: Thu May 22, 2014 1:53 pm Post subject: |
|
|
Centurion
Joined: 28 May 2012 Posts: 146 Location: PL
|
Hi,
Yes sir. For several hours I was looking for working example but everything what I found was not working :/
Thanks a lot for your reply. My code is working now
I don't like the documentation for MQ API. It doesn't show relationship between arguments, for example:
Code: |
request.addParameter (CMQCFC.MQIACH_CHANNEL_TYPE, CMQXC.MQCHT_ALL ); |
There is no information that CMQCFC.MQIACH_CHANNEL_TYPE can have CMQXC.MQCHT_ALL attribute. Or maybe I read it wrong :/
Next step is to display channel status. I assume I cannot do that within CMQCFC.MQCMD_INQUIRE_CHANNEL and I will have to use CMQCFC.MQCMD_INQUIRE_CHANNEL_STATUS for that for every channel from a list. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu May 22, 2014 3:41 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You can use wildcard names for channel status too.
Just don't be surprised if some channels do not return a status. They are in "inactive" status and are fine.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
hughson |
Posted: Fri May 23, 2014 6:03 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
kordi wrote: |
I don't like the documentation for MQ API. It doesn't show relationship between arguments. There is no information that CMQCFC.MQIACH_CHANNEL_TYPE can have CMQXC.MQCHT_ALL attribute. |
You can see the values that are expected here
where it shows:-
ChannelType (MQCFIN)
Channel type (parameter identifier: MQIACH_CHANNEL_TYPE).
If this parameter is present, eligible channels are limited to the specified type. Any attribute selector specified in the ChannelAttrs list which is only valid for channels of a different type or types is ignored; no error is raised.
If this parameter is not present (or if MQCHT_ALL is specified), channels of all types are eligible. Each attribute specified must be a valid channel attribute selector (that is, it must be one from the following list), but it might not be applicable to all (or any) of the channels returned. Channel attribute selectors that are valid but not applicable to the channel are ignored, no error messages occur, and no attribute is returned.
The value can be:
MQCHT_SENDER
Sender.
MQCHT_SERVER
Server.
MQCHT_RECEIVER
Receiver.
MQCHT_REQUESTER
Requester.
MQCHT_SVRCONN
Server-connection (for use by clients).
MQCHT_CLNTCONN
Client connection.
MQCHT_CLUSRCVR
Cluster-receiver.
MQCHT_CLUSSDR
Cluster-sender.
MQCHT_MQTT
Telemetry channel.
MQCHT_ALL
All types.
The default value if this parameter is not specified is MQCHT_ALL. _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
kordi |
Posted: Sat May 24, 2014 4:05 am Post subject: |
|
|
Centurion
Joined: 28 May 2012 Posts: 146 Location: PL
|
Thanks a lot for your feedback.
I use docs delivered with MQ client and this is a nightmare for me.
Morag, can you please give me a full link to online MQ API?
Thanks once again!
Cheers
Kordian |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat May 24, 2014 9:33 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
|
Back to top |
|
 |
kordi |
Posted: Sun May 25, 2014 4:20 am Post subject: |
|
|
Centurion
Joined: 28 May 2012 Posts: 146 Location: PL
|
|
Back to top |
|
 |
kordi |
Posted: Sun May 25, 2014 11:31 am Post subject: |
|
|
Centurion
Joined: 28 May 2012 Posts: 146 Location: PL
|
Guys,
I moved one step forward with my tool, but what I dont understand now is why I get printed MQJE001 message everytime channel status is not found while this exception is handled by printing out "Channel status not found" in line 120 and I should not get any additional mesage for this exception.
Do you have idea why I get it?
Thanks a lot in advance!
Code: |
import java.io.*;
import java.util.*;
import com.ibm.mq.*;
import com.ibm.mq.pcf.*;
public class mqCheck {
public static void main(String[] args) {
//PCFMessageAgent agent;
PCFMessage request;
PCFMessage[] responses;
PCFMessageAgent agent = new PCFMessageAgent();
request = new PCFMessage(CMQCFC.MQCMD_INQUIRE_CHANNEL);
request.addParameter(CMQCFC.MQCACH_CHANNEL_NAME, "*");
request.addParameter(CMQCFC.MQIACH_CHANNEL_TYPE, CMQXC.MQCHT_ALL);
request.addParameter(CMQCFC.MQIACF_CHANNEL_ATTRS, new int[] {
CMQCFC.MQIACF_ALL
});
try {
//PCFMessageAgent agent = new PCFMessageAgent();
agent.connect("192.168.1.153", 1414, "MQADMIN.MO71.SVRCONN");
System.out.println("Połaczono");
} catch (MQException ex) {
System.out.println("A WebSphere MQ Error occured : Completion Code " + ex.completionCode + " Reason Code " + ex.reasonCode);
ex.printStackTrace();
for (Throwable t = ex.getCause(); t != null; t = t.getCause()) {
System.out.println("... Caused by ");
t.printStackTrace();
}
}
try {
// send the request and collect the responses
responses = agent.send(request);
for (int i = 0; i < responses.length; i++) {
// get the channel name and trim the spaces
String temp = responses[i].getStringParameterValue(CMQCFC.MQCACH_CHANNEL_NAME);
String channelName = temp.trim();
// get the channel description and trim the spaces
temp = responses[i].getStringParameterValue(CMQCFC.MQCACH_DESC);
String description = temp.trim();
String checkStatus = checkChannelStatus(channelName, agent);
System.out.println("chl: " + channelName + " STATUS: " + checkStatus + " DESC(" + description + ")");
}
} catch (PCFException pcfEx) {
System.out.println("A WebSphere PCF Error occured : Completion Code " + pcfEx.completionCode + " Reason Code " + pcfEx.reasonCode);
pcfEx.printStackTrace();
} catch (MQException ex) {
System.out.println("A WebSphere MQ Error occured : Completion Code " + ex.completionCode + " Reason Code " + ex.reasonCode);
ex.printStackTrace();
for (Throwable t = ex.getCause(); t != null; t = t.getCause()) {
System.out.println("... Caused by ");
t.printStackTrace();
}
} catch (Exception e) {
System.out.println("exception");
e.printStackTrace();
}
try {
agent.disconnect();
System.out.println("Rozłaczono");
} catch (MQException e) {
// We'll silently ignore it in this demonstration program
}
}
private static String checkChannelStatus(String channelName, PCFMessageAgent agent) throws Exception {
// set up the PCF agent
PCFMessage request;
PCFMessage[] responses;
String chs = "";
// 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, channelName);
// add a parameter designating the instance type (current) desired
request.addParameter(CMQCFC.MQIACH_CHANNEL_INSTANCE_TYPE, CMQC.MQOT_CURRENT_CHANNEL);
// add a parameter designating the attributes desired, but first...
// ...build an array list of attributes desired
int[] attrs = {
CMQCFC.MQCACH_CHANNEL_NAME,
CMQCFC.MQCACH_CONNECTION_NAME,
CMQCFC.MQIACH_MSGS,
CMQCFC.MQCACH_LAST_MSG_DATE,
CMQCFC.MQCACH_LAST_MSG_TIME,
CMQCFC.MQIACH_CHANNEL_STATUS
};
// ...now add the parameter for these attributes
request.addParameter(CMQCFC.MQIACH_CHANNEL_INSTANCE_ATTRS, attrs);
System.out.println("lklklklk");
try {
// send the request and collect the responses
responses = agent.send(request);
for (int i = 0; i < responses.length; i++) {
int chlStatus = responses[i].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"
};
chs = chStatusText[chlStatus];
}
} catch (PCFException pcfEx) {
switch (pcfEx.reasonCode) {
case CMQCFC.MQRCCF_CHL_STATUS_NOT_FOUND:
{
System.out.println("Channel status not found");
break;
}
default:
System.out.println("PCF Exception NOT!! handled in ChannelStatus");
throw pcfEx;
}
}
return chs;
}
}
|
|
|
Back to top |
|
 |
|