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 Installation/Configuration Support » Problem in recieving the messages from the Remote Queue..

Post new topic  Reply to topic
 Problem in recieving the messages from the Remote Queue.. « View previous topic :: View next topic » 
Author Message
Praveen
PostPosted: Tue Dec 17, 2002 1:24 am    Post subject: Problem in recieving the messages from the Remote Queue.. Reply with quote

Apprentice

Joined: 23 Oct 2002
Posts: 40
Location: Bangalore

Hi All,
I am posting my piece of code here, the basic functionality of the code is to send the message and recieve it back from the remote machine..

Code:
import com.ibm.mq.*;
import java.io.*;


public class MQSample
{
   private String qManager = "QM"; // My Queue Manager name

   private MQQueueManager qMgr;

   public static void main(String args[]) {
      new MQSample();
   }

   public MQSample(){
      try{
         qMgr = new MQQueueManager(qManager);
            int openOptions = MQC.MQOO_OUTPUT ;

         MQQueue system_default_local_queue = qMgr.accessQueue("SEND.QUEUE", openOptions);

         // Where SEND.QUEUE is the local definiton of the remote queue.


         MQMessage hello_world = new MQMessage();
         hello_world.writeString("Hello World as a String!");

         MQPutMessageOptions pmo = new MQPutMessageOptions();

         system_default_local_queue.put(hello_world,pmo);


         int newOptions = MQC.MQOO_OUTPUT | MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQGMO_WAIT;

         MQQueue rec_system_default_local_queue = qMgr.accessQueue("RECIEVE.QUEUE", newOptions);

         // Where RECIEVE.QUEUE is the remote definition of local queue to recieve the messages..

           // get the message back again...
           // First define a MQ message buffer to receive the message into..
         MQMessage retrievedMessage = new MQMessage();
           //   retrievedMessage.messageId = hello_world.messageId;
         //editRecvMsgText.setText ("");  // clear old text
           // Set the get message options..
         MQGetMessageOptions gmo = new MQGetMessageOptions();  // accept the defaults
           // same as MQGMO_DEFAULT

         gmo.waitInterval = 60000;

           // get the message off the queue..
         rec_system_default_local_queue.get(retrievedMessage,
                                    gmo,
                                    100);              // max message size

         // And prove we have the message by displaying the UTF message text

         String msgText = retrievedMessage.readUTF();
       //  editRecvMsgText.setText (msgText);
         System.out.println("The message is: " + msgText);
 
         system_default_local_queue.close();

         qMgr.disconnect();
      }
         catch (MQException ex)
      {
            System.out.println("An MQSeries error occurred : Completion code " + ex.completionCode + " Reason code " + ex.reasonCode);
      }

      catch (java.io.IOException ex)
      {
         System.out.println("An error occurred whilst writing to the message buffer: " + ex);
      }
   }
}

When I try to run the program I am getting Error Code as 2033.. Can you suggest me where I am going wrong here...
_________________
Thanks,

Praveen K
Back to top
View user's profile Send private message
vennela
PostPosted: Tue Dec 17, 2002 7:00 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

Praveen:

I guess the problem is with the MessageId. In your PUT you are not supplying any MessageId. MQ would generate a unique MessageId for you. You can use this MessageId to retrieve the Message.
This is what I suspect is happening
You PUT at QM1. Capture the MessageId.
This message goes to the other QMGR(say QM2). Some application reads the message and PUTs. Here another MessageId is generated. This message comes back to the QM1.
At QM1 you are trying to GET with the first MessageId.

That's what you need to look at.
---
Venny
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MichaelR
PostPosted: Tue Dec 17, 2002 7:36 am    Post subject: 2033 Reply with quote

Apprentice

Joined: 20 May 2002
Posts: 37
Location: Tampa

Praveen,

Should we assume there is a companion application (1) reading the message from your OUTPUT queue and (2) moving the message to your INPUT queue.

It appears that your application is processing your INPUT queue in a FIFO manner because you haven't set the MessagId property of your Message Object. If this is the case, your program SHOULD fetch any message it finds in your INPUT queue.

Have you confirmed that a message actually exists in your INPUT queue?

Cheers,

MichaelR
Back to top
View user's profile Send private message
MichaelR
PostPosted: Tue Dec 17, 2002 7:38 am    Post subject: 2033 Reply with quote

Apprentice

Joined: 20 May 2002
Posts: 37
Location: Tampa

Praveen,

Ooops. You are setting the MessageId. Guess I need to get some glasses. Again, I would start by confirming that a message is actually
in your INPUT queue.

Cheers,

MichaelR
Back to top
View user's profile Send private message
Praveen
PostPosted: Tue Dec 17, 2002 7:50 am    Post subject: Reply with quote

Apprentice

Joined: 23 Oct 2002
Posts: 40
Location: Bangalore

Hi,
Yes you are right.. there is other application which is recieving the messages and sending it again. Can you tell me how to set the MessageId in my put messages.. It will be of great help..
_________________
Thanks,

Praveen K
Back to top
View user's profile Send private message
vennela
PostPosted: Tue Dec 17, 2002 9:23 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

Code:
MQMessage hello_world = new MQMessage();
         hello_world.writeString("Hello World as a String!");


Change it to
Code:
MQMessage hello_world = new MQMessage();
         String msgIdString = "myMessage";
         byte[] msgId = msgIdString.getBytes();
         hello_world.messageId = msgId;
         hello_world.writeString("Hello World as a String!");


         


This is how I usually do because I find it easy working with Strings. Hope this helps
---
Venny
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Praveen
PostPosted: Tue Dec 17, 2002 9:41 am    Post subject: Reply with quote

Apprentice

Joined: 23 Oct 2002
Posts: 40
Location: Bangalore

Venny,
I had added same piece of code in my program.... but still getting the same error 2033 Help Please..
_________________
Thanks,

Praveen K
Back to top
View user's profile Send private message
vennela
PostPosted: Tue Dec 17, 2002 10:36 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

In your GET part of the program the MessageId part of it is commented. I haven't looked at that in the first run. So that's not the problem.
Is the PUT successful. Could you GET the message on the other end.
Are all the channels running. If you PUT a message at QM1 does it end up at QM2... and if you PUT a message at QM2 does it end up at QM1. Did you define XMITQs RemoteQ definitions and all the required MQ objects.
WHERE is the message that's PUT
Guess you have to give little more description of your setup ...
---
Venny
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Praveen
PostPosted: Tue Dec 17, 2002 10:47 am    Post subject: Reply with quote

Apprentice

Joined: 23 Oct 2002
Posts: 40
Location: Bangalore

Venny,

In my setup RECIEVE.QUEUE is the local queue.. When I try to put the message by "amqsput RECIEVE.QUEUE QM" and get it back by giving "amqsget RECIEVE.QUEUE QM", its working fine. So what I tried is changed my program accordingly i,e I am trying to put the message on RECIEVE.QUEUE and getting it back from the same queue. There are no other changes in the program.. I had included even messageId also. But this time when I am trying to run it's giving the IO exception

Error: An error occurred whilst writing to the message buffer: java.io.EOFException..
What is the problem here? when I am able to do it by these commands it should work even with program right.. correct me if I am wrong.
_________________
Thanks,

Praveen K
Back to top
View user's profile Send private message
vennela
PostPosted: Tue Dec 17, 2002 11:09 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

But in your program you are PUTting to one queue and GETting grom a different queue?
Specifically SEND.QUEUE and RECEIVE.QUEUE

---
Venny
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Praveen
PostPosted: Tue Dec 17, 2002 11:17 am    Post subject: Reply with quote

Apprentice

Joined: 23 Oct 2002
Posts: 40
Location: Bangalore

Yes thats true.... where SEND.QUEUE is the local def of remote queue of another application and RECIEVE.QUEUE is my local queue. As it was not working properly, for my testing purpose I am trying to put the message on my local queue and getting it back from the same queue through my program. Hope I am not confusing you. Sorry for the trouble..
_________________
Thanks,

Praveen K
Back to top
View user's profile Send private message
vennela
PostPosted: Tue Dec 17, 2002 11:39 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

OK.
Let me put this all together
At QM1:
A localQ RECEIVE.QUEUE
A remoteQ SEND.QUEUE
At QM2:
A localQ SEND.QUEUE
A remoteQ RECEIVE.QUEUE

An Application at QM1 is PUTting to SEND.QUEUE and waiting on RECEIVE.QUEUE

An application at QM2 is GETting on SEND.QUEUE and replying back to RECEIVE.QUEUE.

Is that right. I am assuming you have the channels both ways and transmission queues set up.
Which application is failing: Application at QM1 or application at QM2.

---
Venny
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Praveen
PostPosted: Tue Dec 17, 2002 11:46 am    Post subject: Reply with quote

Apprentice

Joined: 23 Oct 2002
Posts: 40
Location: Bangalore

Venny,
Whatever you had written is exactly right. As I had explained earlier I am using RECIEVE.QUEUE for my testing purpose now, but later I need to use SEND.QUEUE, I am doing this temporarly to show something working by tommorow morning . When I am putting the messages to RECIEVE.QUEUE by the program I am able to browse the messages by amqsgbr but I am not able to get it through the program. Now its giving the error code as 2036 i,e queue is not open for browse.
Thanks....Thanks...
_________________
Thanks,

Praveen K
Back to top
View user's profile Send private message
mqonnet
PostPosted: Wed Dec 18, 2002 6:21 am    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

Praveen,

Know what.... Sometimes it takes longer to find such silly mistakes than tougher ones. Thats what happened to me. Scratched my head quite a bit as to whats wrong in this code. Silly me...

Check this out....

int newOptions = MQC.MQOO_OUTPUT | MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQGMO_WAIT;

This explains everything. You were trying to open a queue specifying GMO_WAIT. You have to use MQGMO_WAIT as gmo option and not Open option. And thus your app was never waiting even though you specified a long wait interval. Modify your app to this.

int newOptions = MQC.MQOO_OUTPUT | MQC.MQOO_INPUT_AS_Q_DEF;

gmo.options = MQC.MQGMO_WAIT.

Cheers
Kumar
_________________
IBM Certified WebSphere MQ V5.3 Developer
IBM Certified WebSphere MQ V5.3 Solution Designer
IBM Certified WebSphere MQ V5.3 System Administrator
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Installation/Configuration Support » Problem in recieving the messages from the Remote 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.