Author |
Message
|
Jeffrey P |
Posted: Wed Oct 01, 2003 6:06 am Post subject: Browsing the Queue |
|
|
Novice
Joined: 27 Aug 2003 Posts: 20
|
Im wanting to do some processing on messages from a particular queue. All I need to do is get all of the messages on the queue and process them accordingly. My question is, do I have to set up the browsing options or can I just loop through the messages based on MyQueue.getCurrentDepth() and do a "get" on each iteration? Thanks.
Jeff _________________ Jeff |
|
Back to top |
|
 |
mqonnet |
Posted: Wed Oct 01, 2003 6:19 am Post subject: |
|
|
 Grand Master
Joined: 18 Feb 2002 Posts: 1114 Location: Boston, Ma, Usa.
|
You would need to browse only when you think you dont need to remove the message off the queue completely. If you have to remove the messages completely/destructively, then you should not use browse options in GMO. Looking at your description, it seems that you wish to do some processing/manipulations on the message itself. In that case you should not use browse options.
Cheers
Kumar |
|
Back to top |
|
 |
Jeffrey P |
Posted: Wed Oct 01, 2003 6:26 am Post subject: Browsing the queue |
|
|
Novice
Joined: 27 Aug 2003 Posts: 20
|
Thanks, I really appreciate it. Upon further review however, Ive discovered that I will in fact need to browse. Think Jeff, think!!! I take it that if I do set the browse options that when I do a "get", the message will not be taken off of the queue. How do I get the message officially off of the queue if after browsing I determine that it is a message that I need to process? Im assuming that I will need to reset the browse options accordingly based on each message but not sure. Also, do I have to keep setting the options to MQC.MQGMO_BROWSE_NEXT to get to the next message or just loop based on the queue depth? Thanks a bunch! _________________ Jeff |
|
Back to top |
|
 |
vennela |
Posted: Wed Oct 01, 2003 6:55 am Post subject: Re: Browsing the queue |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Jeffrey P wrote: |
just loop based on the queue depth? Thanks a bunch! |
I am not sure if this is possible because we can't get the number of messages in the queue |
|
Back to top |
|
 |
Jeffrey P |
Posted: Wed Oct 01, 2003 7:10 am Post subject: browsing queue |
|
|
Novice
Joined: 27 Aug 2003 Posts: 20
|
Wouldnt the getCurrentDepth method on the MQQueue object work for getting the number of messages on the queue? _________________ Jeff |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Oct 01, 2003 7:20 am Post subject: Re: browsing queue |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Jeffrey P wrote: |
Wouldnt the getCurrentDepth method on the MQQueue object work for getting the number of messages on the queue? |
Only if you've opened the queue with the Inquiry open option.
But if you loop over MQC.MQGMO_BROWSE_NEXT, you'll get a 2033 (no more messages on the queue) when you reach the end. So you don't need to bother to count. Plus, this way, you don't have to worry about the queue depth *changing* while you're reading the queue - which you do if you haven't opened the queue for exclusive input. _________________ I am *not* the model of the modern major general.
Last edited by jefflowrey on Wed Oct 01, 2003 9:11 am; edited 1 time in total |
|
Back to top |
|
 |
mqonnet |
Posted: Wed Oct 01, 2003 7:36 am Post subject: |
|
|
 Grand Master
Joined: 18 Feb 2002 Posts: 1114 Location: Boston, Ma, Usa.
|
The way you could do this is something like this.
while (rc != 2033)
{
Browse msgs... with browse next.
If msg == the message you were looking for....
then do a destructive get...
else
carry on...
}
Unless the if condition is satisfied the message always stays back on the queue.
Cheers
Kumar |
|
Back to top |
|
 |
Jeffrey P |
Posted: Wed Oct 01, 2003 8:01 am Post subject: |
|
|
Novice
Joined: 27 Aug 2003 Posts: 20
|
If running in browse mode, how do we specify a "destructive" get? Do we just change the get options for each message based on whether to process it or not? Thanks. _________________ Jeff |
|
Back to top |
|
 |
mqonnet |
Posted: Wed Oct 01, 2003 8:13 am Post subject: |
|
|
 Grand Master
Joined: 18 Feb 2002 Posts: 1114 Location: Boston, Ma, Usa.
|
You got it...!!!
while (rc != 2033)
{
Browse msgs... with browse next.
gmo = browse.
If msg == the message you were looking for....
gmo = anything - browse.
then do a destructive get...
else
carry on...
}
Cheers
Kumar |
|
Back to top |
|
 |
Jeffrey P |
Posted: Wed Oct 01, 2003 8:22 am Post subject: |
|
|
Novice
Joined: 27 Aug 2003 Posts: 20
|
Thanks for all the help. _________________ Jeff |
|
Back to top |
|
 |
|