Author |
Message
|
-=mrdoc=- |
Posted: Wed Sep 20, 2006 6:23 am Post subject: Connecting to server with MQQueueConnectionFactory |
|
|
Newbie
Joined: 20 Sep 2006 Posts: 4 Location: Warsaw
|
Hi,
strange think, I have MQ on my computer and one MQ on server.
I can connect to my computer with this code:
public class AGFactoryConn {
private static final String qManager = "qmlocal";
private static final String qName = "queuelocal";
private static final String channel = "SYSTEM.DEF.SVRCONN";
private static final String hostname = "192.168.1.165";
private static final String message = "aloha!";
private static final int port = 1415;
private static final int CCSID=1208;
public static void main(String[] args) { new AGFactoryConn().Run();}
public void Run()
{
try {
MQQueueConnectionFactory factory = new MQQueueConnectionFactory();
factory.setQueueManager(qManager);
factory.setCCSID(CCSID);
factory.setChannel(channel);
factory.setHostName(hostname);
factory.setPort(port);
System.out.println("creating queue connection");
QueueConnection connection= factory.createQueueConnection();
System.out.println("starting qconn");
connection.start();
System.out.println("creating session");
QueueSession session= connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
//queue
Queue ioQueue ;
ioQueue = session.createQueue( qName );
QueueSender sender = session.createSender(ioQueue);
TextMessage outmessage;
outmessage = session.createTextMessage();
outmessage.setText(message) ;
sender.send(outmessage);
System.out.println("done!!");
} catch (JMSException e) { e.printStackTrace();}} }
but I cannot connect to remote server when I change variables to:
private static final String qManager = "DEV.362.MGR";
private static final String qName = "ASYNCH.SOKX.TO.EAI.1";
private static final String channel = "SYSTEM.DEF.SVRCONN";
private static final String hostname = "126.177.38.142";
private static final String message = "aloha!";
private static final int port = 1414;
private static final int CCSID=1208;
I get error:
javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'DEV.362.MGR'
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:586)
at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2110)
at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1532)
at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:150)
at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:60)
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:171)
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:112)
at websphere.AGFactoryWM.Run(AGFactoryWM.java:59)
at websphere.AGFactoryWM.main(AGFactoryWM.java:33)
but at the same time I'don have any problems to connect to this serwer with this code:
MQEnvironment.hostname = hostname;
MQEnvironment.channel = channel;
MQEnvironment.port = port;
MQEnvironment.CCSID=CCSID;
MQQueueManager qMgr = new MQQueueManager(qManager);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
System.out.println("Accessing queue: "+qName);
MQQueue queue = qMgr.accessQueue(qName, openOptions);
MQMessage msg = new MQMessage();
msg.format=MQC.MQFMT_STRING;
msg.writeUTF("aloha!!");
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put(msg, pmo);
I have no idea why it doesn't work.... what do You think
? |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 20, 2006 6:39 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Well, if your output included the LinkedException that came with the JMSException, then you'd have the MQ Reason Code that would tell you exactly why you get a failure.
And if that reason code was 2035 or 2059 or 2009, you'd have a lot of search results you could read. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 20, 2006 2:10 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
I think it is because even though he passed all the parameters for the remote connection he forgot to change his transport to Client. _________________ MQ & Broker admin |
|
Back to top |
|
 |
-=mrdoc=- |
Posted: Thu Sep 21, 2006 1:20 am Post subject: |
|
|
Newbie
Joined: 20 Sep 2006 Posts: 4 Location: Warsaw
|
I have Reason Code 2058 which means "Queue manager name not valid or not known." but it make no sense...
I'm sorry but I'm not shure what does I mean "change transport to Client"
Thanks!
-=mrdoc=- |
|
Back to top |
|
 |
-=mrdoc=- |
Posted: Thu Sep 21, 2006 1:44 am Post subject: |
|
|
Newbie
Joined: 20 Sep 2006 Posts: 4 Location: Warsaw
|
ok, now I see
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzaw.doc/csqzaw1464.htm
"Choosing client or bindings transport
WebSphere MQ JMS can communicate with WebSphere MQ using either client or bindings transport. (However, client transport is not supported on z/OS(R).) If you use the Java bindings, the JMS application and the WebSphere MQ queue manager must be located on the same machine. If you use the client, the queue manager can be on a different machine from the application......." |
|
Back to top |
|
 |
wschutz |
Posted: Thu Sep 21, 2006 1:51 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
In the three examples, you are using client bindings..
The IP address are different in the first two examples and the qmgrnames are different .... are you sure that you actually have those qmgrs running at those IP addresses? Can you use the sample amqscnxc to connect using those parms? _________________ -wayne |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Sep 21, 2006 1:55 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
MQRC 2058 means that you specified a queue manager name that is not the same as the queue manager name that you successfully opened a network connection to.
For example, suppose I have two qmgrs on the same machine. One is listening to port 1414 and the other is listening to port 1415. If I connect to port 1415 but specify the name for the first queue manager, I'll get a 2058.
The most frequent causes of 2058, though, are a) connecting to a local queue manager using a bindings connection instead of connecting to a remote queue manager using a client connection, and b) forgetting that MQ is case sensitive and specifying the queue manager name in the wrong case. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
-=mrdoc=- |
Posted: Thu Sep 21, 2006 2:48 am Post subject: |
|
|
Newbie
Joined: 20 Sep 2006 Posts: 4 Location: Warsaw
|
I think fjb_saper was right and problem is :
"...If you use the Java bindings, the JMS application and the WebSphere MQ queue manager must be located on the same machine..."
Now I try to run connecting to server using MQQueueConnectionFactory on server, not on my (remote in server point of view) local computer.
I'll let You know if it's working.
Thank You all for help. |
|
Back to top |
|
 |
|