ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Connecting to server with MQQueueConnectionFactory

Post new topic  Reply to topic
 Connecting to server with MQQueueConnectionFactory « View previous topic :: View next topic » 
Author Message
-=mrdoc=-
PostPosted: Wed Sep 20, 2006 6:23 am    Post subject: Connecting to server with MQQueueConnectionFactory Reply with quote

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
View user's profile Send private message Visit poster's website
jefflowrey
PostPosted: Wed Sep 20, 2006 6:39 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Wed Sep 20, 2006 2:10 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
-=mrdoc=-
PostPosted: Thu Sep 21, 2006 1:20 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
-=mrdoc=-
PostPosted: Thu Sep 21, 2006 1:44 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
wschutz
PostPosted: Thu Sep 21, 2006 1:51 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
jefflowrey
PostPosted: Thu Sep 21, 2006 1:55 am    Post subject: Reply with quote

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
View user's profile Send private message
-=mrdoc=-
PostPosted: Thu Sep 21, 2006 2:48 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Connecting to server with MQQueueConnectionFactory
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.