|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
AMQ2009 java client problem |
« View previous topic :: View next topic » |
Author |
Message
|
merlin |
Posted: Mon Apr 11, 2005 6:47 am Post subject: AMQ2009 java client problem |
|
|
Novice
Joined: 07 Mar 2004 Posts: 19
|
Hi
In dire need to some assistance from you guys!
Working on a client site, they have a very simple MQ Queue Manager set up on an AIX box. Client java software written to connect to the Queue Manager and post messages onto a queue.
Problem is getting AMQ2009 Connection broken when trying to establish the QueueManager within the java. Here's some code from a sample MQTester doing the MQ part:
package com.byford.qrunner.utils;
import java.io.*;
import com.ibm.mq.*;
public class MQTester{
private String managerName;
private MQQueueManager qm;
private String sendingQueueName;
private MQQueue sendingQueue;
private String replyQueueName;
private MQQueue replyQueue;
private String channel;
private int port;
private String serverAddress;
private String testData;
private int waitFor;
public void setManagerName(String s){
managerName = s;
}
public void setSendingQueueName(String s){
sendingQueueName = s;
}
public void setReplyQueueName(String s){
replyQueueName = s;
}
public void setChannel(String c){
channel = c;
}
public void setPort(int i){
port = i;
}
public void setTestData(String s){
testData = s;
}
public void setServerAddress(String s){
serverAddress = s;
}
public void setWaitFor(int i){
waitFor = i;
}
public MQTester(){
}
public void startMQSession() throws MQException{
MQEnvironment.hostname = serverAddress;
MQEnvironment.port = port;
MQEnvironment.channel = channel;
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
qm = new MQQueueManager(managerName);
openSendQueue();
openReplyQueue();
}
private void openSendQueue() throws MQException{
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE;
sendingQueue = qm.accessQueue(sendingQueueName,openOptions,null,null,null);
}
private void openReplyQueue() throws MQException{
int openOptions = MQC.MQOO_INQUIRE;
openOptions |= MQC.MQOO_INPUT_AS_Q_DEF;
replyQueue = qm.accessQueue(replyQueueName,openOptions,null,null,null);
}
public void sendMessageAndGetReply() throws MQException,IOException{
MQMessage msg = new MQMessage();
msg.encoding = MQC.MQENC_NATIVE;
msg.format = MQC.MQFMT_STRING;
msg.persistence = MQC.MQPER_PERSISTENT;
msg.replyToQueueName = replyQueueName;
msg.replyToQueueManagerName = managerName;
msg.characterSet = 1208;
msg.report = MQC.MQRO_COA;
msg.writeUTF(testData);
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_NEW_MSG_ID;
long start = System.currentTimeMillis();
sendingQueue.put(msg, pmo);
//now get the correl id
byte [] correlId = msg.messageId;
StringBuffer sb = new StringBuffer();
for(int i=0;i<correlId.length;i++){
sb.append((char)correlId[i]);
}
System.out.println("Correl ID="+sb);
//create new MQMessage obj to receive in reply
MQMessage replyMessage = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.matchOptions = MQC.MQMO_MATCH_CORREL_ID;
gmo.options = MQC.MQGMO_WAIT;
gmo.waitInterval = waitFor;//max time to wait for bailing
replyMessage.correlationId = correlId;
System.out.println("About to try to get reply message, depth is "+replyQueue.getCurrentDepth());
replyQueue.get(replyMessage,gmo);
long end = System.currentTimeMillis();
System.out.println("Put message to MQ and got suitable Reply message in "+(end-start)+" ms");
}
public static void main(String args[]){
if(args!=null && args.length== {
//do test
MQTester m = new MQTester();
m.setServerAddress(args[0]);
String p = args[1];
try{
int i = Integer.parseInt(p);
m.setPort(i);
m.setChannel(args[2]);
m.setManagerName(args[3]);
m.setSendingQueueName(args[4]);
m.setReplyQueueName(args[5]);
m.setTestData(args[6]);
int i2 = Integer.parseInt(args[7]);
m.setWaitFor(i2);
m.startMQSession();
m.sendMessageAndGetReply();
}
catch(NumberFormatException nfe){
printUsage();
}
catch(Exception e){
e.printStackTrace();
}
}
else{
printUsage();
}
}
private static void printUsage(){
System.out.println("Usage: java com.byford.qrunner.utils.MQTester [hostservernetaddress] [hostserverport] [channelname] [MQQueueMgrName] [MQQueuetosendto] [MQReplyQueue] [teststring] [millisecondstowaitforreply]");
}
}
and here's the trace when the connection fails:
MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE003: IO error transmitting message buffer
MQJE001: Completion Code 2, Reason 2009
com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2009
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:172)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:270)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:290)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:80)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:150)
at com.ibm.mq.MQQueueManager.obtainBaseMQQueueManager(MQQueueManager.java:682)
at com.ibm.mq.MQQueueManager.construct(MQQueueManager.java:620)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:393)
at com.ats.mq.MQTester.startMQSession(MQTester.java:62)
at com.ats.mq.MQTester.main(MQTester.java:129)
Any thoughts please? I can assure you that the Queue manager is running when the code is invoked, also that the listener is up and the parameters are correct, i.e. QM name etc |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Apr 11, 2005 6:50 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Can you put messages from the client machine using amsqputc, or one of the sample java programs? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
bower5932 |
Posted: Mon Apr 11, 2005 9:13 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
I'd also like to know the version of the code on both the server and client. |
|
Back to top |
|
 |
merlin |
Posted: Tue Apr 12, 2005 12:29 am Post subject: |
|
|
Novice
Joined: 07 Mar 2004 Posts: 19
|
Hi
MQ version is 5.3, at CSD09 on AIX.
I will suggest to the client that they try amqsputc: can someone just refresh my memory on what the differences are between these two sample programs?
When running my trusty java test class, I got the same problem as experienced when their app tried to invoke the Queue Manager.
Thanks everyone,
Marcus |
|
Back to top |
|
 |
malammik |
Posted: Tue Apr 12, 2005 5:24 am Post subject: |
|
|
 Partisan
Joined: 27 Jan 2005 Posts: 397 Location: Philadelphia, PA
|
amqsputc is for client connections. Have u verified that the listener is running on the queue manager? Have you verified with some other trusty utility that you can connect to that queue manager? If you are connecting on 1414, have you tried telneting into that port and see if you get connection. _________________ Mikhail Malamud
http://www.netflexity.com
http://groups.google.com/group/qflex |
|
Back to top |
|
 |
merlin |
Posted: Thu Apr 14, 2005 11:28 pm Post subject: |
|
|
Novice
Joined: 07 Mar 2004 Posts: 19
|
Hi
Have verified that telnet into the port works, yes, which confirms that the Listener is running ok.
In my absence, the problem appears to have been resolved, through - I think - starting some other service in MQ, since now when the client app connects, it is able to issue commands and actually put/get messages.
Before it was able to connect, but not even create the QueueManager object in the java, the connection would simply timeout everntually.
Any one know what this extra service was that they located and got running so that the java started working?
Thanks |
|
Back to top |
|
 |
bower5932 |
Posted: Fri Apr 15, 2005 6:31 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
merlin wrote: |
Before it was able to connect, but not even create the QueueManager object in the java, the connection would simply timeout everntually.
Any one know what this extra service was that they located and got running so that the java started working? |
If you couldn't create QueueManager object, I'm not sure how connected you were. I'd be suspicious of somebody starting/stopping the listener while you were running. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|