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 » Problem accessing alias queue

Post new topic  Reply to topic
 Problem accessing alias queue « View previous topic :: View next topic » 
Author Message
jalummoo
PostPosted: Tue Sep 03, 2002 2:56 pm    Post subject: Problem accessing alias queue Reply with quote

Newbie

Joined: 30 Aug 2002
Posts: 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
View user's profile Send private message
RogerLacroix
PostPosted: Tue Sep 03, 2002 8:55 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
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
View user's profile Send private message Visit poster's website
nimconsult
PostPosted: Tue Sep 03, 2002 10:13 pm    Post subject: Reply with quote

Master

Joined: 22 May 2002
Posts: 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
View user's profile Send private message Send e-mail Visit poster's website
mrlinux
PostPosted: Wed Sep 04, 2002 5:09 am    Post subject: Reply with quote

Grand Master

Joined: 14 Feb 2002
Posts: 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
View user's profile Send private message Send e-mail
RogerLacroix
PostPosted: Wed Sep 04, 2002 8:01 am    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
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
View user's profile Send private message Visit poster's website
jalummoo
PostPosted: Sat Sep 07, 2002 4:35 pm    Post subject: Reply with quote

Newbie

Joined: 30 Aug 2002
Posts: 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
View user's profile Send private message
nimconsult
PostPosted: Sun Sep 08, 2002 10:29 pm    Post subject: Reply with quote

Master

Joined: 22 May 2002
Posts: 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
View user's profile Send private message Send e-mail Visit poster's website
jalummoo
PostPosted: Mon Sep 09, 2002 4:05 pm    Post subject: Reply with quote

Newbie

Joined: 30 Aug 2002
Posts: 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
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 » Problem accessing alias queue
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.