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 » MQSeries API error in Java program

Post new topic  Reply to topic
 MQSeries API error in Java program « View previous topic :: View next topic » 
Author Message
prk
PostPosted: Mon Jun 05, 2006 9:26 am    Post subject: MQSeries API error in Java program Reply with quote

Centurion

Joined: 17 Feb 2004
Posts: 102

Here is my environment..
Windows 2003, MQ 5.3 CSD 09, Message Broker Toolkit 6.0

I am working on coding in Java within the EJBClient file generated using wsdl. I want to create a program which can Put and Get messages from queue parameters specified by the user and here is the code.
I am getting an error on the line ( qMgr = new MQQueueManager(qManager) ; ). When I change it to qMgr = new MQQueueManager(qManager, channel) ; I get the following error.
The constructor MQQueueManager(String, String) is undefined

Please help me, any help is greatly appreciated. Whats the correct way to resolve these errors.
----------------------------------------------------------------------------
I am importing import com.ibm.mq.*;

String hostName = "MYHOST" ;
String channel = "JAVA.CHANNEL" ;
String qManager = "MYQMGR" ;
String qName = "d_in" ;
//String connectionName = "localhost";

// Set up the MQEnvironment properties for Client Connections
MQEnvironment.hostname = hostName ;
MQEnvironment.channel = channel ;
MQEnvironment.port = 1414 ;

String connectionName="SYSTEM.DEF.SVRCONN/TCP/localhost(1414)";

MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES);

// Connection To the Queue Manager
final MQQueueManager qMgr;
qMgr = new MQQueueManager(qManager) ;
//MQQueueManager qMgr=new MQQueueManager();


/* Set up the open options to open the queue for out put and
additionally we have set the option to fail if the queue manager is
quiescing.
*/
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING ;

// Open the queue
//MQQueue queue = qMgr.accessQueue(qName, openOptions,null,null,null);
MQQueue queue = qMgr.accessQueue(qName, openOptions);

// Set the put message options , we will use the default setting.
MQPutMessageOptions pmo = new MQPutMessageOptions();

/* Next we Build a message The MQMessage class encapsulates the data buffer
that contains the actual message data, together with all the MQMD
parameters
that describe the message.
To Build a new message, create a new instance of MQMessage class and use
writxxx (we will be using writeString method). The put() method of
MQQueue also
takes an instance of the MQPutMessageOptions class as a parameter.
*/
MQMessage outMsg = new MQMessage(); //Create The message buffer
outMsg.format = MQC.MQFMT_STRING ; // Set the MQMD format field.


// Prepare message with user data
String msgString = "Test Message Using MQ Java API ";
outMsg.writeString(msgString);

// Now we put The message on the Queue
queue.put(outMsg, pmo);

// Commit the transaction.
qMgr.commit();
System.out.println(" The message has been Sussesfully put\n\n#########");

// Close the the Queue and Queue manager objects.
queue.close();
qMgr.disconnect();
Back to top
View user's profile Send private message
wschutz
PostPosted: Mon Jun 05, 2006 9:46 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Quote:
Constructors
MQQueueManager

public MQQueueManager(String queueManagerName) throws MQException;
Creates a connection to the named queue manager.

The host name, channel name and port to use during the connection request are specified in the MQEnvironment class. This must be done before calling this constructor

_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
prk
PostPosted: Mon Jun 05, 2006 10:15 am    Post subject: Reply with quote

Centurion

Joined: 17 Feb 2004
Posts: 102

Wayne,
I have done all the MQEnvironment stuff before the call to the constructor (shown in the code above) but I wtill get the same error. Is there anything else that I am missing.
Back to top
View user's profile Send private message
wschutz
PostPosted: Mon Jun 05, 2006 10:23 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

What error? This one:
Quote:
I get the following error.
The constructor MQQueueManager(String, String) is undefined
??

That's because you can't specify the channel name on the qmgr constructor.
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
prk
PostPosted: Mon Jun 05, 2006 12:06 pm    Post subject: Reply with quote

Centurion

Joined: 17 Feb 2004
Posts: 102

You are correct Wayne, thats the error I get. If I just pass the queue manager name without channel or connection names I get lots of other errors.
Here is how I resolved the issue. I have put it in the try/catch loop and the issues is resolved. I still need to do further testing but thanks for your help.
Back to top
View user's profile Send private message
8davitt
PostPosted: Tue Jun 06, 2006 12:02 am    Post subject: Reply with quote

Apprentice

Joined: 06 Feb 2003
Posts: 37
Location: Seated in front of monitor

Hello prk, One thing that you should consider is which messaging API you should use. Within J2EE (EJBs) the recommended messaging API is JMS. Try to avoid using the MQ Java API in this kind of environment.

/s
Back to top
View user's profile Send private message
prk
PostPosted: Tue Jun 06, 2006 5:40 am    Post subject: Reply with quote

Centurion

Joined: 17 Feb 2004
Posts: 102

Thanks 8davitt.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQSeries API error in Java program
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.