This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Websphere and the fly likes Help With Simple Java MQ Connection? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Help With Simple Java MQ Connection?" Watch "Help With Simple Java MQ Connection?" New topic
Author

Help With Simple Java MQ Connection?

LeRoy Michaelson
Greenhorn

Joined: Jun 12, 2006
Posts: 2
I am new to using MQ, but need to do the seemingly simplest task. I need a Java client program to make a MQ connection and send a string over that connection to a server.

Here is what I know.

- I have installed the MQ Client v5.3 on Windows XP.
- I have received a .tab file from the server group.
- I have configured the environment properly, enabling me to use amqsputc to successfully send a message to the server.

Now comes the rub. I have been trying to use the sample MSender.java to write that same message from a Java program, but can't get to first base. If I try the following:

qMgr = new MQQueueManager( qManagerName );

I get the following error:

java.lang.UnsatisfiedLinkError: no mqjbnd05 in java.library.path

The file mqjbnd05 doesn't come with the client distribution, it comes with the full distribution. So I tried the following:

java.util.Hashtable props = new java.util.Hashtable();
props.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
qMgr = new MQQueueManager( qManagerName, props );

Now it doesn't look for the server libraries, but I get a different error:

MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE011: Socket connection attempt refused
MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE011: Socket connection attempt refused
WMQ exception occurred : Completion code 2 Reason code 2059

I've been pulling my hair out for weeks, and can't get this to work. If anyone could help me get the simplest "Hello MQ World" to work, I would be grateful.
Rob Doughty
Greenhorn

Joined: Jun 16, 2006
Posts: 10
Hi,
Happy to help but have to ask the obvious questions first..
2059 normally means that the queue manager is not available.. can I assume that you have a) Created the queue manager using the crtmqm command (or whatever the command is these days) and b) started the queue manager (strmqm).

There also needs to be an mq listener running which I think was the runmqlsr -m <Qmgr> -p <port number> -t tcp (Im assuming your using TCP)
command.

Check these things and if your still having probs write back.

Rob


Senior Architect<br />Sun Certified Enterprise Architect <br />IBM Certified Specialist MQ Series<br />IBM Certified Specialist Rational Unified Process<br />IBM Certified Developer Websphere Portal 5.1
Rob Doughty
Greenhorn

Joined: Jun 16, 2006
Posts: 10
Wait up... ignore last post (just read your post properly)..
Have you set the following MQEnvironment properties correctly before trying the
MQQueueManager call....

MQEnvironment.hostname = "my.mqsvr.com"; // host to connect to
MQEnvironment.port = 1414; // port to connect to.
// If I don't set this,
// it defaults to 1414
// (the default WebSphere MQ port)
MQEnvironment.channel = "channel.name"; // the CASE-SENSITIVE
// name of the
// SVR CONN channel on
// the queue manager
MQQueueManager qMgr = new MQQueueManager("MYQMGR");

Rob
Rob Doughty
Greenhorn

Joined: Jun 16, 2006
Posts: 10
Also if you notice in the applet code below the properties have to be stored in the MQEnvironment object. In fact the code below should provide you with all you need to connect to the server. Good luck




Syed Mahdi
Ranch Hand

Joined: Aug 27, 2004
Posts: 45
Hi all

I know this is a very old post but I am getting the same error. I am rtying to connect to a remote host, my code looks exactly like the Rpb gave but i still get this error.



I am connecting to remote host so why is it looking for this dll here locally. In case of a remote host it should not look for dlls, this is what i think.

I will appreciate any help. I have searched the net and most of the time they say to change your Queue binding to Client, which doesnt work in my case as I dont have a local MQ server.

Thanks in advance.
 
Consider Paul's rocket mass heater.
 
subject: Help With Simple Java MQ Connection?
 
Similar Threads
Websphere MQ Socket issue
MQ ssl problem in Linux
createQueueConnection failed
MQWebsphere(MQJE001: An MQException occurred: Completion Code 2, Reason 2059)
WSAD5.1.3 remote MQv5.3 connection and listen using MDB