Author |
Message
|
brandoh |
Posted: Thu Oct 19, 2006 10:52 am Post subject: Read all messages from a queue |
|
|
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 |
|
 |
zpat |
Posted: Thu Oct 19, 2006 10:59 am Post subject: |
|
|
 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 |
|
 |
brandoh |
Posted: Thu Oct 19, 2006 11:08 am Post subject: |
|
|
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 |
|
 |
brandoh |
Posted: Thu Oct 19, 2006 11:10 am Post subject: |
|
|
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 |
|
 |
zpat |
Posted: Thu Oct 19, 2006 11:48 am Post subject: |
|
|
 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 |
|
 |
brandoh |
Posted: Thu Oct 19, 2006 11:52 am Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Thu Oct 19, 2006 4:10 pm Post subject: |
|
|
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 |
|
 |
kevinf2349 |
Posted: Thu Oct 19, 2006 4:47 pm Post subject: |
|
|
 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 |
|
 |
|