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 API Support » Read all messages from a queue

Post new topic  Reply to topic
 Read all messages from a queue « View previous topic :: View next topic » 
Author Message
brandoh
PostPosted: Thu Oct 19, 2006 10:52 am    Post subject: Read all messages from a queue Reply with quote

Newbie

Joined: 18 Oct 2006
Posts: 8

Sorry for all of the dumb questions, but is there any pseudo code or code snippets out there for reading all messages from a queue? I am putting a command on SYSTEM.COMMAND.INPUT and then trying to read the messages off of the replyToQueue. I can read the first message fine, but subsequent calls of queue.get fail with a 2033, no message available.

Im assuming that I need to advance to the next message in the queue, but I have not been able to determine how to do that.
Back to top
View user's profile Send private message
zpat
PostPosted: Thu Oct 19, 2006 10:59 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Clear the MQMD.MSGID and MQMD.CORRELID fields to binary zeros before each MQGET.

Last edited by zpat on Thu Oct 19, 2006 11:47 am; edited 1 time in total
Back to top
View user's profile Send private message
brandoh
PostPosted: Thu Oct 19, 2006 11:08 am    Post subject: Reply with quote

Newbie

Joined: 18 Oct 2006
Posts: 8

I see the matchOptions in the MQGetMessageOptions fields, but I see no method to set them to 0. How is this done?
Back to top
View user's profile Send private message
brandoh
PostPosted: Thu Oct 19, 2006 11:10 am    Post subject: Reply with quote

Newbie

Joined: 18 Oct 2006
Posts: 8

Also, I should mention that this code is java, and I am using the MQ Base classes for java.
Back to top
View user's profile Send private message
zpat
PostPosted: Thu Oct 19, 2006 11:48 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

You're the Java coder, not me!

Something like creating a new instance of a message object?

RTM.....I only know Ye Olde programming languages!
Back to top
View user's profile Send private message
brandoh
PostPosted: Thu Oct 19, 2006 11:52 am    Post subject: Reply with quote

Newbie

Joined: 18 Oct 2006
Posts: 8

I think I have found it, some obscure doc from IBM.

for (int i = 0; i < qDepth; i++){
rcvMessage.clearMessage();
rcvMessage.correlationId = MQC.MQCI_NONE;
rcvMessage.messageId = MQC.MQMI_NONE;

replyQueue.get(rcvMessage, gmo);
messages[i] = rcvMessage.readLine();

}

the clearMessage, and MQCI/MQMI_NONE seem to do the trick.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Oct 19, 2006 4:10 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

NO.

DO NOT LOOP OVER THE QUEUE DEPTH.

Loop Infinitely until you get an Exception that is an MQRC 2033 (No more messages!).

You will be in for a world of unexplained problems if you leave the code the way it is.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kevinf2349
PostPosted: Thu Oct 19, 2006 4:47 pm    Post subject: Reply with quote

Grand Master

Joined: 28 Feb 2003
Posts: 1311
Location: USA

well maybe not toally unexplained. but sure as eggs are eggs the next post is going to ask if any one has come across this MQ bug (Nigel....that was sarcasm )
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 API Support » Read all messages from a 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.