| Author | Message | 
		
		  | jalummoo | 
			  
				|  Posted: Tue Sep 03, 2002 2:56 pm    Post subject: Problem accessing alias queue |   |  | 
		
		  | Newbie
 
 
 Joined: 30 Aug 2002Posts: 3
 
 
 | 
			  
				| Hi, 
 Here is my problem..
 I am using 2 java clients, one to put a message into a queue and another to retrieve it.by defining 2 aliases,  one for input and one
 for output. When I put messages into the output queue,
 it works fine. However when I try to get the messages
 using the second queue it gives me error "2068". I can open the queue fine. However when I try to get the messages in the queue, it fails with error code "2068". The
 open options I've tried to use are MQOO_INPUT_AS_Q_DEF
 and MQC.MQOO_INQUIRE. If I only use
 MQOO_INPUT_AS_Q_DEF, I get error "2038" which
 basically says I've to use inquire options. I've tried to use many combinations of open and get options, with no avail... Again, I am able to put the message into queue ok, but not able to retrieve it. Here are the stack traces for "2038" and "2068", followed by the queue definition statements.
 
 STACKTRACES
 ==========
 MQJE001: Completion Code 2, Reason 2038
 An MQSeries error occurred : Completion code 2 Reason
 code 2038
 com.ibm.mq.MQException: MQJE001: Completion Code 2,
 Reason 2038
 at
 com.ibm.mq.MQManagedObject.inquire(MQManagedObject.java:257)
 at
 com.ibm.mq.MQManagedObject.getInt(MQManagedObject.java:428)
 at
 com.ibm.mq.MQQueue.getCurrentDepth(MQQueue.java:1385)
 at MQReceiver.main(MQReceiver.java:46)
 
 MQJE001: Completion Code 1, Reason 2068
 An MQSeries error occurred : Completion code 1 Reason
 code 2068
 com.ibm.mq.MQException: MQJE001: Completion Code 1,
 Reason 2068
 at
 com.ibm.mq.MQManagedObject.inquire(MQManagedObject.java:257)
 at
 com.ibm.mq.MQManagedObject.getInt(MQManagedObject.java:428)
 at
 com.ibm.mq.MQQueue.getCurrentDepth(MQQueue.java:1385)
 at MQReceiver.main(MQReceiver.java:46)
 
 Queue Definition
 ==========
 DEFINE QLOCAL('JAVAQ2') REPLACE  +
 DESCR('Base Queue for MQSeries') +
 PUT (ENABLED) +
 GET (ENABLED)
 
 DEFINE QALIAS ('PUT.QUEUE') +
 TARGQ ('JAVAQ2') +
 PUT (ENABLED) +
 GET (DISABLED)
 
 DEFINE QALIAS ('GET.QUEUE') +
 TARGQ ('JAVAQ2') +
 PUT (DISABLED) +
 GET (ENABLED)
 
 DEFINE CHANNEL('JAVACH2') CHLTYPE(SVRCONN) REPLACE
 +
 TRPTYPE(TCP) MCAUSER(' ')
 
 Any response highly appreciated. Thanks.
 
 Joseph Alummoottil
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | RogerLacroix | 
			  
				|  Posted: Tue Sep 03, 2002 8:55 pm    Post subject: |   |  | 
		
		  |  Jedi Knight
 
 
 Joined: 15 May 2001Posts: 3265
 Location: London, ON  Canada
 
 | 
			  
				| Wow, you are right. I can duplicate it on my Win2000 box with MQ 5.2 CSD04 with the latest version (April 2002) MA88 (Sun Java v1.4.0). 
 Hello Hursley, (ground control to Major Tom), we have a bug.  I cannot do either a destructive get or non-destructive get against an alias queue.
 
 later
 Roger...
 _________________
 Capitalware: Transforming tomorrow into today.
 Connected to MQ!
 Twitter
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | nimconsult | 
			  
				|  Posted: Tue Sep 03, 2002 10:13 pm    Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 22 May 2002Posts: 268
 Location: NIMCONSULT - Belgium
 
 | 
			  
				| I can run this simple program without any problem on a W2K, MQ5.2, JDK1.3: 
 
 
   
	| Code: |  
	| import com.ibm.mq.*;
 
 class FirstMQ
 {
 public static void main(String[] args)
 {
 try
 {
 MQQueueManager qm = new MQQueueManager("");
 MQQueue q = qm.accessQueue("AQ.TEST", MQC.MQOO_INPUT_AS_Q_DEF);
 
 MQMessage msg = new MQMessage();
 
 q.get(msg);
 
 System.out.println("Message: " + msg.readLine());
 
 q.close();
 qm.disconnect();
 }
 catch(MQException e)
 {
 System.out.println("MQ Error: cc=" + e.completionCode + ", reason=" + e.reasonCode);
 }
 catch(java.io.IOException e)
 {
 System.out.println("IO Error: " + e);
 }
 }
 }
 
 |  
 Are you sure that you are doing a simple get? The backtrace gives me the impression that you are doing a getCurrentDepth?
 _________________
 Nicolas Maréchal
 Senior Architect - Partner
 
 NIMCONSULT Software Architecture Services (Belgium)
 http://www.nimconsult.be
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mrlinux | 
			  
				|  Posted: Wed Sep 04, 2002 5:09 am    Post subject: |   |  | 
		
		  |  Grand Master
 
 
 Joined: 14 Feb 2002Posts: 1261
 Location: Detroit,MI USA
 
 | 
			  
				| Well I have no trouble executing the above example on JDK 1.4.0 either with the latest MA88 
 maybe you could post your code and we can try it ???
 _________________
 Jeff
 
 IBM Certified Developer MQSeries
 IBM Certified Specialist MQSeries
 IBM Certified Solutions Expert MQSeries
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | RogerLacroix | 
			  
				|  Posted: Wed Sep 04, 2002 8:01 am    Post subject: |   |  | 
		
		  |  Jedi Knight
 
 
 Joined: 15 May 2001Posts: 3265
 Location: London, ON  Canada
 
 | 
			  
				| That is what happens when you are tired and you try to do a quicky test.  You guys are correct - for me it works fine.  I had multiple layers of classes and when I looked at the lowest level I had a "getCurrentDepth()" call.  Hence, the error on an alias queue. 
 later
 Roger...
 _________________
 Capitalware: Transforming tomorrow into today.
 Connected to MQ!
 Twitter
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jalummoo | 
			  
				|  Posted: Sat Sep 07, 2002 4:35 pm    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 30 Aug 2002Posts: 3
 
 
 | 
			  
				| Thanks for all the responses. Some progress has been made. It turns out I did have a getCurrentDepth() call in my code
 and I removed it, and used only MQOO_INPUT_AS_Q_DEF as
 the open option and works fine. However this does not
 completely solve my problem since I am using the
 getCurrentDepth() method to find out the # of msgs in
 the queue and iteratively print the messages.
 
 Why does getCurrentdepth() not work, even when used
 with the inquire option MQC.MQOO_INQUIRE (getting
 "2068"). Are we not supposed to use getCurrentdepth()
 on an alias queue, even when used with the inquire
 option MQC.MQOO_INQUIRE, or is this a bug? If we're
 not, are there any alternatives to querying an alias
 queue to find out the number of messages in the base
 queue that it resolves to? Any responses highly
 appreciated. Thanks.
 
 PS: Following is the class ("MQReceiver.java") that I used to test using TCP/IP to access MQSeries 5.2 on Win2K.
 
 
 
 
   
	| Code: |  
	| import com.ibm.mq.*;
 import java.io.*;
 import java.util.Properties;
 
 public class MQReceiver
 {
 private String qmgr_name;   // Queue Manager name
 private MQQueueManager qmgr;   // Queue Manager to connect to with the above name
 private String qname;      // Queue Name
 private MQQueue queue;      // Queue to connect to with the above name
 private String channel;      // Channel
 private String hostname;    // Host and port to connect to
 private int   port;
 private String get_msg;    // GET message
 
 // Default port and msg if not provided
 private static final int DEFAULT_PORT = 1414;
 private static final int EMPTY_QUEUE  = 2033;
 
 public MQReceiver()
 {
 // Initialize variables
 qmgr_name = "JAVAMQM2";
 qname = "GET.QUEUE";
 //qname = "JAVAQ2"; //base queue
 channel = "JAVACH2";
 hostname = "spr93122.central.sprint.com";
 port = 1514;
 MQEnvironment.hostname = hostname;
 MQEnvironment.port = port;
 MQEnvironment.channel = channel;
 }
 
 
 public static void main(String args[])
 {
 MQReceiver mq = new MQReceiver();
 try
 {
 // Queue Manager must be initialized after the env. variables are set
 //Uncomment if you need tracing. Also can add a log file param -- e.g. (2, logfilename)
 //MQEnvironment.enableTracing(2);
 mq.qmgr = new MQQueueManager(mq.qmgr_name);
 mq.open();
 // queue depth gets decremented with each get()
 // queue depth will not work for alias queue, even if inquire option is used.
 for (int i=0; i<depth; i++)
 System.out.println("Retrieved message: \n" + mq.get());
 mq.close();
 }
 catch (MQException mqex)
 {
 if (mqex.reasonCode == EMPTY_QUEUE)
 {
 System.err.println("An MQSeries error occurred : Attempt to get messages from an empty queue!");
 }
 else
 {
 System.err.println("An MQSeries error occurred : Completion code " +
 mqex.completionCode + " Reason code " + mqex.reasonCode);
 }
 mqex.printStackTrace();
 }
 catch (IOException ioex)
 {
 System.err.println("An error occurred whilst writing to the message buffer: " + ioex);
 ioex.printStackTrace();
 }
 }
 
 public void open() throws MQException
 {
 // Set up the options on the queue we wish to open...
 // Note. All MQSeries Options are static variables
 int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_INQUIRE;
 //int openOptions = MQC.MQOO_INPUT_AS_Q_DEF;
 queue =   qmgr.accessQueue(qname, openOptions);
 System.out.println("Connected to Queue: \"" + qname + "\" on Queue Manager: \"" +  qmgr_name + "\"");
 }
 
 public String get() throws IOException, MQException
 {
 MQMessage mq_msg  = new MQMessage();
 MQGetMessageOptions gmo = new MQGetMessageOptions();
 queue.get(mq_msg,gmo);  // has default values
 queue.get(mq_msg);  // has default values
 System.out.println("Message Length = " + mq_msg.getMessageLength());
 return mq_msg.readUTF();
 }
 
 public void close() throws MQException
 {
 queue.close();
 qmgr.disconnect();
 }
 }
 
 
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | nimconsult | 
			  
				|  Posted: Sun Sep 08, 2002 10:29 pm    Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 22 May 2002Posts: 268
 Location: NIMCONSULT - Belgium
 
 | 
			  
				| 1- you should not use "getCurrentDepth" to read all the messages of the queue, but instead perform mq.get until the queue is empty, this is a safer and more efficient programming practice. See http://www.mqseries.net/phpBB2/viewtopic.php?t=4989 for a discussion on the subject. 
 2- you cannot read the current depth of an alias queue. You have to resolve the base queue name and read the depth of the base queue.
 _________________
 Nicolas Maréchal
 Senior Architect - Partner
 
 NIMCONSULT Software Architecture Services (Belgium)
 http://www.nimconsult.be
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jalummoo | 
			  
				|  Posted: Mon Sep 09, 2002 4:05 pm    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 30 Aug 2002Posts: 3
 
 
 | 
			  
				| Thank you for all the responses. That answered all the questions that I had. I must say this is one of the best forums I've ever seen. Replies are promptly posted and questions answered. Thanks again and keep up the good work. |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |