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 » Subsequent get not getting

Post new topic  Reply to topic
 Subsequent get not getting « View previous topic :: View next topic » 
Author Message
MABeatty1978
PostPosted: Tue Sep 22, 2015 8:52 am    Post subject: Subsequent get not getting Reply with quote

Acolyte

Joined: 17 Jul 2014
Posts: 54

I've got a java application the executes an externam process which puts several messages on a queue. It does a Process.waitFor() and when the process completes, it gets the messages

Code:
boolean moreMessages = true;
int mqoo = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT | MQConstants.MQOO_INQUIRE;
MQQueue tmpQueue = qmgr.accessQueue("SYSTEM.DEFAULT.MODEL.QUEUE", mqoo, qManagerName, dynQName, null );
gmo.options = MQConstants.MQGMO_WAIT;
gmo.waitInterval = 10000;
MQMessage = new MQMessage();

while (moreMessages) {
   try{
      log.write("Curr depth1: " + tmpQueue.getCurrentDepth());
      tmpQueue.get(msg, gmo);
      log.write("Curr depth2: " + tmpQueue.getCurrentDepth());
    }
    catch{
         
         if (rc = 2033){
              log.write("Curr depth3: " + tmpQueue.getCurrentDepth());
              log.write("No messages Available");
              moreMessages = false;
         }
    }

}


When I run the program I get the following:
Curr depth1: 6
Curr depth2: 5;
Curr depth1: 5
----- there is a 10 second delay -----
Curr depth3: 5
No Messages Available

What is going on here? Clearly there are still 5 more messags available, so why is it going into the Exception block with mqrc 2033?


Last edited by MABeatty1978 on Tue Sep 22, 2015 9:02 am; edited 1 time in total
Back to top
View user's profile Send private message
MABeatty1978
PostPosted: Tue Sep 22, 2015 9:01 am    Post subject: Reply with quote

Acolyte

Joined: 17 Jul 2014
Posts: 54

It happens every time.... mess around for 4 hours trying to figure it out...

Give up and go to the boards....

Figure it out less than 2 minutes later.

Problem was that I defined my MQMessage msg outside of the while loop so msg was still populated when it got to the second iteration.

The solution was to move the MQMessage msg = new MQMessage(); into the while loop so a new message was insantiated each time around.

Though.... can someone explain why? Why didn't MQ just get the next message and over write the old one?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Sep 22, 2015 9:06 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Because you were asking it to get a message with the same MsgID.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
tczielke
PostPosted: Tue Sep 22, 2015 11:17 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

Another option is to keep the code the way it was but add this into your loop after you get the message:

Quote:

Arrays.fill(msg.messageId, (byte) 0);
Arrays.fill(msg.correlationId, (byte) 0);


I write Java with a C mentality, so allocating the same object over and over again offends my programming sensibilities.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Sep 22, 2015 11:32 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

tczielke wrote:
I write Java with a C mentality


You should teach that to Vitor.

_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
tczielke
PostPosted: Tue Sep 22, 2015 11:34 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

You should see my Java code . . . .
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Sep 22, 2015 11:37 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

tczielke wrote:
You should see my Java code . . . .


You should see Vitor's...

I mean, if there were any...

_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Sep 22, 2015 12:29 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

That drink I promised to buy you at MQTC - how do you take your hemlock? Straight? On the rocks?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Sep 22, 2015 6:51 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Vitor wrote:
That drink I promised to buy you at MQTC - how do you take your hemlock? Straight? On the rocks?

On the rocks with a splash of Absinthe....
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Wed Sep 23, 2015 4:57 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

fjb_saper wrote:
Vitor wrote:
That drink I promised to buy you at MQTC - how do you take your hemlock? Straight? On the rocks?

On the rocks with a splash of Absinthe....


_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
tczielke
PostPosted: Wed Sep 23, 2015 5:01 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

I think Socrates preferred hemlock neat . . .
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Sep 23, 2015 5:02 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

tczielke wrote:
I think Socrates preferred hemlock neat . . .

Socrates himself was permanently pissed.
_________________
chmod -R ugo-wx /
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 » Subsequent get not getting
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.