Author |
Message
|
Sowmya |
Posted: Wed Feb 04, 2009 11:23 am Post subject: Message Count |
|
|
Newbie
Joined: 03 Feb 2009 Posts: 3
|
HI,
How do get the count of messages from the Queue using .net API.
thanks
Sowmya |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Feb 04, 2009 11:26 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
MQGET each one, and increment a local variable. |
|
Back to top |
|
 |
Sowmya |
Posted: Wed Feb 04, 2009 11:31 am Post subject: Message Count |
|
|
Newbie
Joined: 03 Feb 2009 Posts: 3
|
thanks for the reply.
I didnt get your point.
I want to use the TotalCount of messages in the loop and read one by one message data.
Is there a way to get the total number of messages in the queue in .NET.
Thanks
Sowmya |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Feb 04, 2009 11:32 am Post subject: Re: Message Count |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Sowmya wrote: |
I want to use the TotalCount of messages in the loop and read one by one message data. |
No.
You don't.
You want to read each message off the queue until you are told that there are no more messages. |
|
Back to top |
|
 |
Sowmya |
Posted: Wed Feb 04, 2009 11:34 am Post subject: Message Count |
|
|
Newbie
Joined: 03 Feb 2009 Posts: 3
|
yes that is the goal.Let me know the method name if possible.
thanks
sowmya |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Feb 04, 2009 11:40 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I'm sure the documentation is much more authoritative than I am.
Happy Searching, Reading, Thinking and Learning.
 |
|
Back to top |
|
 |
Vitor |
Posted: Wed Feb 04, 2009 12:26 pm Post subject: Re: Message Count |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Sowmya wrote: |
yes that is the goal.Let me know the method name if possible.
|
Either read the documentation or look at the sample code.
(You'll notice none of the sample code counts messages and loops. There's a reason for this. You'll find this reason, along with the answer to your question, has been previously posted on the forum many times if you care to search for it) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
VijayGoparaju` |
Posted: Thu Feb 05, 2009 12:27 am Post subject: |
|
|
Acolyte
Joined: 26 Aug 2008 Posts: 72
|
Hi Sowmya,
You can use this method:MQC.MQGMO_BROWSE_NEXT
Thanks..
Vijay |
|
Back to top |
|
 |
zpat |
Posted: Thu Feb 05, 2009 12:41 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Don't do that.
You don't need to know the depth. Just process the messages with MQGET until MQRC 2033 is returned (which could be on the first attempt if the queue is empty).
Awareness of depth causes problems when messages arrive or leave during your program's execution.
Browsing should only be used for special reasons not in standard applications.
I suppose it might be OK to MQINQ on the depth before starting to process a queue if it's non-zero, but make sure that you then loop until 2033 and don't loop for the depth value (as it may have already changed). |
|
Back to top |
|
 |
Vitor |
Posted: Thu Feb 05, 2009 1:15 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
VijayGoparaju` wrote: |
You can use this method:MQC.MQGMO_BROWSE_NEXT
|
Aside from not doing what the poster wants without other code you've not mentioned, the browse cursor is very inefficient. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|