Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help With Simple Java MQ Connection?

 
LeRoy Michaelson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rob Doughty
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic