Author |
Message
|
shalinithulasi |
Posted: Thu May 24, 2007 5:21 am Post subject: How to get the message depth from MQueue |
|
|
Newbie
Joined: 24 May 2007 Posts: 4
|
Hi,
I wanted to get the message depth in an MQueue.
I am using the following method to get depth which I got while googling for MQQueue.
MQQueue queue = null;
//Create Q here
int ret=queue.getCurrentDepth();
But I am getting compilation error that method doesnot exist.
I am using MQ Series ver 5.2.
Any idea of the issue?
Shalu |
|
Back to top |
|
 |
PeterPotkay |
Posted: Thu May 24, 2007 5:44 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
Why do you want to know the q depth? If you are going to use it to determine if you should do another MQGET, that is wrong. Do a search here to find out why.
Unless you are writing a monitoring program, apps don't need to know the q depth. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
Vitor |
Posted: Thu May 24, 2007 10:44 am Post subject: Re: How to get the message depth from MQueue |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
shalinithulasi wrote: |
I am using MQ Series ver 5.2.
|
You also want to use a more up to date version.
Though this will not make reading the queue depth in a standard app a good thing to do. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
shalinithulasi |
Posted: Thu May 24, 2007 11:02 pm Post subject: get depth of Q |
|
|
Newbie
Joined: 24 May 2007 Posts: 4
|
Hi,
My requirement is to get the messages that were there in Q before when my app started..
During one run of app, it should not pick msgs coming simultaneously to the Q. It should pick those msgs during nxt run.
I thought if I know the count, it's easy to iterate that many times only and exit my app.
Guide me if I am wrong.
Shalu |
|
Back to top |
|
 |
Vitor |
Posted: Fri May 25, 2007 12:27 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
This is a bad design - queues should not be used to hold messages. Nor is it too wise to fill the queue while you/re emptying it - imagine what will happen if someone down the line changes the queue from FIFO to priority!
Your app should ideally read the queue until empty. If you have this deadline wierd thing, read the messages under syncpoint until you find one with a put datetime after your app started, then roll it back and stop.
But this is still not a good design _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
shalinithulasi |
Posted: Fri May 25, 2007 1:06 am Post subject: |
|
|
Newbie
Joined: 24 May 2007 Posts: 4
|
Thanks..
but do you know that getcurrentdepth() fn is avail for MQ ver5.3.
Or is it avail from any later versions? |
|
Back to top |
|
 |
shalinithulasi |
Posted: Fri May 25, 2007 1:10 am Post subject: |
|
|
Newbie
Joined: 24 May 2007 Posts: 4
|
Thanks..
but do you know that getcurrentdepth() fn is avail for MQ ver5.3.
Or is it avail from any later versions? |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Fri May 25, 2007 2:12 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
shalinithulasi wrote: |
Thanks..
but do you know that getcurrentdepth() fn is avail for MQ ver5.3.
Or is it avail from any later versions? |
Yes,
There is method getCurrentDepth() of MQQueue class. _________________ Marcin |
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri May 25, 2007 5:01 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
shalinithulasi wrote: |
Thanks..
but do you know that getcurrentdepth() fn is avail for MQ ver5.3.
Or is it avail from any later versions? |
Sigh. You are still going to code it the wrong way, aren't you?
OK, here's a hint why this is bad.
So, you get the current depth, its 100 and you say you are going to do 100 gets. What if some of those 100 messages were expired? What if some were uncommitted? What if some were locked? (you will still do your 100 gets and now risk getting newer messages!)
Bad Design!  _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
|