Author |
Message
|
dstrower |
Posted: Fri May 06, 2005 8:31 am Post subject: How can I get the last 100 messages from a queue? |
|
|
Newbie
Joined: 02 May 2005 Posts: 3
|
I need to look at the last 100 messages in a large queue.
I am currently opening the queue and using a loop to run the get() command multiple times until I get to the 100 messages.
Is there an easier way to do this? |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri May 06, 2005 8:43 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Why is that a "hard" way to do this?
No, there is no other way to do this. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
vennela |
Posted: Fri May 06, 2005 12:14 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
How can somebody do it?
The first 100 messages is doable. If the PUTter is running how will someone find the last 100 messages? |
|
Back to top |
|
 |
PeterPotkay |
Posted: Sat May 07, 2005 6:48 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
MQINQ the depth, subtract 100 to get n, browse up to n, then start destructive gets.
This will only work if you can guarantee that no more messages will arrive after you find out what n is. Since you can't guarantee that, this is just a bad idea. I suppose if you program had the autority to MQSET the queue to PUT_DISABLED, then MQINQ the depth, then subract 100 to get n, then get the last 100, and then MQSET to PUT_ENABLE the queue, it would work, but now you got a PUT_DISABLED queue. What problems is that going to cause?
Unless you can guarantee that no more mesages will arrive, you should not bother with this design of pulling the last 100.
What are you really trying to do? What's so special about these last 100 messages? _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
bower5932 |
Posted: Mon May 09, 2005 5:50 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
I would think that any program that was designed to read through messages with no intention of doing something with them would be a bad design. There is no telling how many CPU cycles you'll be burning to do nothing. If there is something special about these messages, you can consider grouping them together and then getting messages in a group. |
|
Back to top |
|
 |
kspranava |
Posted: Mon May 16, 2005 12:26 am Post subject: move cursor option |
|
|
 Centurion
Joined: 27 Apr 2003 Posts: 124
|
Hi All,
Is there any option to move the msg cursor directly to a particular message by giving the msg seq. no. Also, is there any option to trace msgs backwards like MQGMO_BROWSE_PREVIOUS?
Thanks in advance. |
|
Back to top |
|
 |
bob_buxton |
Posted: Mon May 16, 2005 1:44 am Post subject: Re: move cursor option |
|
|
 Master
Joined: 23 Aug 2001 Posts: 266 Location: England
|
kspranava wrote: |
Hi All,
Is there any option to move the msg cursor directly to a particular message by giving the msg seq. no. Also, is there any option to trace msgs backwards like MQGMO_BROWSE_PREVIOUS?
Thanks in advance. |
If you know the message id and/or correlid and/or groupid you can specify them as match options with a browse first request and the browse cursor will be positioned at the first matching messages. You could then use browse next without match options to browse sequentially forward from that point.
There are no backwards browse or get options. _________________ Bob Buxton
Ex-Websphere MQ Development |
|
Back to top |
|
 |
bob_buxton |
Posted: Mon May 16, 2005 1:49 am Post subject: |
|
|
 Master
Joined: 23 Aug 2001 Posts: 266 Location: England
|
PeterPotkay wrote: |
MQINQ the depth, subtract 100 to get n, browse up to n, then start destructive gets. |
This wouldn't work - the browse cursor has no effect on destructive gets which will get the first message on the queue.
However a Browse next, Get message under cursor loop for the last hundred should work. _________________ Bob Buxton
Ex-Websphere MQ Development |
|
Back to top |
|
 |
|