Author |
Message
|
sudheeratwork |
Posted: Tue Jun 14, 2005 2:33 pm Post subject: How do I check if there are any messages in a queue |
|
|
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 |
|
 |
vennela |
Posted: Tue Jun 14, 2005 2:42 pm Post subject: |
|
|
 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 |
|
 |
sudheeratwork |
Posted: Tue Jun 14, 2005 3:15 pm Post subject: Thanks pal |
|
|
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 |
|
 |
jefflowrey |
Posted: Tue Jun 14, 2005 4:54 pm Post subject: Re: Thanks pal |
|
|
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 |
|
 |
csmith28 |
Posted: Tue Jun 14, 2005 8:01 pm Post subject: |
|
|
 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 |
|
 |
bower5932 |
Posted: Wed Jun 15, 2005 4:47 am Post subject: |
|
|
 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 |
|
 |
sudheeratwork |
Posted: Wed Jun 15, 2005 1:54 pm Post subject: Am I missing something here |
|
|
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 |
|
 |
jefflowrey |
Posted: Wed Jun 15, 2005 2:00 pm Post subject: Re: Am I missing something here |
|
|
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 |
|
 |
sudheeratwork |
Posted: Wed Jun 15, 2005 2:01 pm Post subject: I was refering this |
|
|
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 |
|
 |
jefflowrey |
Posted: Wed Jun 15, 2005 2:38 pm Post subject: Re: I was refering this |
|
|
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 |
|
 |
PeterPotkay |
Posted: Wed Jun 15, 2005 4:58 pm Post subject: Re: I was refering this |
|
|
 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 |
|
 |
sudheeratwork |
Posted: Wed Jun 15, 2005 5:27 pm Post subject: IMHO |
|
|
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 |
|
 |
jefflowrey |
Posted: Thu Jun 16, 2005 3:28 am Post subject: |
|
|
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 |
|
 |
|