ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General Discussion » How do I check if there are any messages in a queue

Post new topic  Reply to topic
 How do I check if there are any messages in a queue « View previous topic :: View next topic » 
Author Message
sudheeratwork
PostPosted: Tue Jun 14, 2005 2:33 pm    Post subject: How do I check if there are any messages in a queue Reply with quote

Novice

Joined: 26 May 2005
Posts: 13

I am using the MQSeries .Net classes in my application and would like to know if there are any messages in the a given queue and if there are any then do my processing.

Can some one plz suggest me the way to do this

thanks
Back to top
View user's profile Send private message
vennela
PostPosted: Tue Jun 14, 2005 2:42 pm    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

You have to get messages in a loop and process them until there are no more messages. You will get a return code of 2033 if there are no more messages available.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sudheeratwork
PostPosted: Tue Jun 14, 2005 3:15 pm    Post subject: Thanks pal Reply with quote

Novice

Joined: 26 May 2005
Posts: 13

This is weird. they could give a much detailed error reason than that rite?

ne ways thanks for the help again
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jun 14, 2005 4:54 pm    Post subject: Re: Thanks pal Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

sudheeratwork wrote:
This is weird. they could give a much detailed error reason than that rite?


It's no weirder than returning 0 to indicate success, which 99% of all C methods/subroutines/functions do.

And what could be more detailed then "There are currently no more messages left on the queue"?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
csmith28
PostPosted: Tue Jun 14, 2005 8:01 pm    Post subject: Reply with quote

Grand Master

Joined: 15 Jul 2003
Posts: 1196
Location: Arizona

How about, "The queue is empty please hold." or The queue you are trying to reach is currently empty. Please check the queuename and try again."
_________________
Yes, I am an agent of Satan but my duties are largely ceremonial.
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed Jun 15, 2005 4:47 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

Of course, you could always say that you want to wait forever and then you'd never get the 2033....
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
sudheeratwork
PostPosted: Wed Jun 15, 2005 1:54 pm    Post subject: Am I missing something here Reply with quote

Novice

Joined: 26 May 2005
Posts: 13

This is all I can get to print from the exception when the queue is empty:

MQExp: CompCode: 2, Reason: 2033
MQExp.Reason: 2033
MQExp.Message: Error in the application.

Am I missing something here ?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jun 15, 2005 2:00 pm    Post subject: Re: Am I missing something here Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

sudheeratwork wrote:
This is all I can get to print from the exception when the queue is empty:

MQExp: CompCode: 2, Reason: 2033
MQExp.Reason: 2033
MQExp.Message: Error in the application.

Am I missing something here ?

What more are you looking for?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
sudheeratwork
PostPosted: Wed Jun 15, 2005 2:01 pm    Post subject: I was refering this Reply with quote

Novice

Joined: 26 May 2005
Posts: 13

I was refering this

Quote:
And what could be more detailed then "There are currently no more messages left on the queue"?


Why is 2033 an application error????

Ok here is what I am doing, tell me if I am doing it wrong..

[code]
queue = queueManager.AccessQueue( QueueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING );
queueMessage = new MQMessage();
queueMessage.Format = MQC.MQFMT_STRING;
queueGetMessageOptions = new MQGetMessageOptions();

try
{
// I tried this and this does not help either
//if(queue.CurrentDepth > 0)
queue.Get( queueMessage, queueGetMessageOptions );
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jun 15, 2005 2:38 pm    Post subject: Re: I was refering this Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

sudheeratwork wrote:
Why is 2033 an application error????

Technically, it's not.

Completion Code 2 means the call completed with a Warning, not an Error.

sudheeratwork wrote:
Ok here is what I am doing, tell me if I am doing it wrong..

What we've been trying to tell you is that regardless of what you think, this is simply the way it works.

Trying to make it do something else is a bad idea.

Write your code to check to see if the Get gave back a 2033 Reason Code. If it did, then proceed as you would if you were able to get a queue depth first, and had counted down until there were no more messages.

Look at the VB samples to see how they handle this. Look at the Java samples to see how they handle getting 2033's.

Read the Application Programming Guide.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Wed Jun 15, 2005 4:58 pm    Post subject: Re: I was refering this Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

jefflowrey wrote:

Completion Code 2 means the call completed with a Warning, not an Error.


Wellllll, atthe risk of confusing the issue, Completion Code 2 = FAILED, and Completion Code 1 = WARNING.

2033 is such a common "error", maybe it should be mapped to CC 1 and not CC 2!
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
sudheeratwork
PostPosted: Wed Jun 15, 2005 5:27 pm    Post subject: IMHO Reply with quote

Novice

Joined: 26 May 2005
Posts: 13

Thank you for responses guys...

just my opinion....
dumb error/warning system.

all the get method returns is a void, rather a bool or int being returned would be real kool....

and what is with the stupid error messages, wish they were more meaningful...

I know the roooooooooooooooooooooooooooooound about now

THREAD CLOSED====================================
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jun 16, 2005 3:28 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

After a certain amount of time programming, you stop caring whether functions have prototypes like
returnType functionName (args)
or
void functionName (args returnType args)

Because, really, the information is the same regardless.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » How do I check if there are any messages in a queue
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.