|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Error 2009 when connecting to Server channel |
« View previous topic :: View next topic » |
Author |
Message
|
OEvans |
Posted: Mon Oct 21, 2002 10:20 am Post subject: Error 2009 when connecting to Server channel |
|
|
Newbie
Joined: 13 Sep 2002 Posts: 6 Location: Vancouver, B.C.
|
I am trying to connect to an Server channel using a java client on remote machines but am getting the following error:
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
MQJE001: Completion Code 2, Reason 2009
Exception in thread "main" com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2009
I have used the same code to connect to a Server Connection channel and it works perfectly. To eliminate the variable I have set up two channels on the same server, same queue manager with one Server Connection channel and one Server channel. The MQ Server is on a Windows 2000 server, I have run the java client from another Windows 2000 machine, an AIX machine and an HP-UX machine. Same result in all cases.
My guess is that I am trying to open the Server channel with the wrong set of open options. Does this sound plausible? I have posted the code below, I appreciate anyone's ideas or suggestions.
import java.io.*;
import com.ibm.mq.*;
public class mqconn
{
public static void main (String[] args)
throws MQException, IOException
{
String testMsg = "";
String qMgr = "QM_Test";
String host = "test";
String channel = "CH_Test";
int port = 1414;
String temp = "";
BufferedReader reader = new BufferedReader(
new InputStreamReader(System.in));
System.out.print("Server hostname (" + host + "): ");
if (!(temp = reader.readLine()).equals(""))
host = temp;
System.out.print("Queue Manager name (" + qMgr + "): ");
if (!(temp = reader.readLine()).equals(""))
qMgr = temp;
System.out.print("Channel name (" + channel + "): ");
if (!(temp = reader.readLine()).equals(""))
channel = temp;
System.out.print("Port (" + Integer.toString(port) + "): ");
if (!(temp = reader.readLine()).equals(""))
port = Integer.parseInt(temp);
System.out.print("Enter a message to send to the queue: ");
testMsg = reader.readLine();
//Set up MQ Environment
MQEnvironment.hostname = host;
MQEnvironment.channel = channel;
MQEnvironment.port = port;
//MQEnvironment.properties.put (MQC.TRANSPORT_PROPERTY,
// MQC.TRANSPORT_MQSERIES);
// Connect to Queue manager
MQQueueManager mq = new MQQueueManager(qMgr); // <-- Exception is thrown here
if (mq.isConnected()){
System.out.println("Connected");
}
else {
System.out.println("Not Connected");
}
// Open queue
int openOptions = MQC.MQOO_INQUIRE + MQC.MQOO_FAIL_IF_QUIESCING +
MQC.MQOO_OUTPUT + MQC.MQOO_INPUT_AS_Q_DEF;
MQQueue queue = mq.accessQueue("Lab", openOptions, null, null, null);
int queueType = queue.getQueueType();
System.out.println("Queue Type: " + Integer.toString(queueType) + "\n");
// Put a message on to the queue
System.out.println("Putting a message on the queue...");
MQMessage msg = new MQMessage();
msg.writeUTF(testMsg);
MQPutMessageOptions pmo = new MQPutMessageOptions(); // Default options
queue.put(msg, pmo);
System.out.println("Message put on the queue\n");
// Get messages from the queue
System.out.println("Getting message from the queue...");
MQMessage getMsg = new MQMessage();
getMsg.messageId = msg.messageId;
MQGetMessageOptions gmo = new MQGetMessageOptions(); // Default options
queue.get(getMsg, gmo);
System.out.println("Got message from the queue");
String outMsg = getMsg.readUTF();
System.out.println("Message received is:\n" + outMsg);
// Close the queue
queue.close();
mq.disconnect();
}
} |
|
Back to top |
|
 |
RogerLacroix |
Posted: Mon Oct 21, 2002 8:10 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
First, MQ objects (e.g. Channel Names) are case sensitive. Check your spelling.
Secondly, when you say "server channel", do you mean "Server Channel" or "Server Connection Channel"? Big difference. A Java client can ONLY use "Server Connection Channel" (aka SVRCONN).
By default, when a queue manager is created a "Server Connection Channel" is created that is called SYSTEM.DEF.SVRCONN. Try using it.
later
Roger... _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
OEvans |
Posted: Tue Oct 22, 2002 9:19 am Post subject: |
|
|
Newbie
Joined: 13 Sep 2002 Posts: 6 Location: Vancouver, B.C.
|
Thanks for the response. I guess I should have read to documentation closer, I was indeed trying to connect to a 'Server Connection' channel which I did not realize I could not do with the Java classes. Although it seems pretty obvious in retrospect.
In any case we have configured another 'Server Connection channel' and it all works nicely.
Thanks again for the help.
oe |
|
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
|
|
|
|