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 » IBM MQ API Support » Check if queue is empty

Post new topic  Reply to topic Goto page 1, 2  Next
 Check if queue is empty « View previous topic :: View next topic » 
Author Message
Zoli
PostPosted: Sun Dec 03, 2006 10:51 am    Post subject: Check if queue is empty Reply with quote

Newbie

Joined: 03 Dec 2006
Posts: 3

Hi,

I am a newbie and trying to check if the queue is empty (0 message) before attempting to get a message. It seems a basic task but I cannot find any solution to it.
Any idea is appreciated.

Thanks.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun Dec 03, 2006 1:46 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Quite easy: in base do a get if it returns with reason code 2033 the queue is empty (no message in a getable state)

In JMS do a receive. If the message is null same story...

If you want the check to be non destructive do a browse. If the browse does not allow you to see any message your queue is empty(no message in a getable/browseable state).

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Zoli
PostPosted: Sun Dec 03, 2006 11:53 pm    Post subject: Reply with quote

Newbie

Joined: 03 Dec 2006
Posts: 3

I managed to do it by checking if the reason code is 2033, but as you say, I would like to make it in a non-destructive way. How would you check the browseable state in C# (if there is a means to do it)?

Thanks for your help.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Dec 04, 2006 3:00 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Don't bother.

Read the first message, destructively. If you get a 2033, then there's nothing more to do for now. If you don't get a 2033, then process the message.

Why do you want to know if you need to get a message before you try to get a message?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Tue Dec 05, 2006 7:18 am    Post subject: Reply with quote

Guest




It is a rare application that would need to know the current depth of a queue without the intent to MQGET the messages.

However, here is how you check to see if there are messages in a queue, but not (attempt to) MQGET them:

1. MQOPEN the queue for inquire; then
2. MQINQuire on current depth; then
3. MQCLOSE the queue.

This is not a best practice for all applications, since you have added three MQI calls. As prior posts suggest, your applications attempt to MQGET a message with either get a message or return a 2033 reason code.
Back to top
kevinf2349
PostPosted: Tue Dec 05, 2006 7:27 am    Post subject: Reply with quote

Grand Master

Joined: 28 Feb 2003
Posts: 1311
Location: USA

Quote:
This is not a best practice for all applications, since you have added three MQI calls.


...and the value for depth may well be inaccurate (expired messages etc).
Back to top
View user's profile Send private message
Zoli
PostPosted: Tue Dec 05, 2006 1:12 pm    Post subject: Reply with quote

Newbie

Joined: 03 Dec 2006
Posts: 3

It seems, I just have to stick to checking the 2033 reason code - simple and works fine...
Thanks all of you for the suggestions.
Back to top
View user's profile Send private message
mvarghese
PostPosted: Fri Dec 08, 2006 12:10 am    Post subject: can i check Qdepth from Message Broker Reply with quote

Centurion

Joined: 27 Sep 2006
Posts: 141

Is it possible to check Qdepth from message broker using ESQL?.so that i can route the message to different destination.
What i know, its not possible ?if yes, please explain how?
_________________
Jain Varghese
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Dec 08, 2006 12:20 am    Post subject: Re: can i check Qdepth from Message Broker Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mvarghese wrote:
Is it possible to check Qdepth from message broker using ESQL?.so that i can route the message to different destination.
What i know, its not possible ?if yes, please explain how?


Can you give us a bit more detail on the requirement? I'm not immediately clear on how qdepth would affect message routing - normally it's content.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
wschutz
PostPosted: Fri Dec 08, 2006 5:38 am    Post subject: Re: can i check Qdepth from Message Broker Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Vitor wrote:
mvarghese wrote:
Is it possible to check Qdepth from message broker using ESQL?.so that i can route the message to different destination.
What i know, its not possible ?if yes, please explain how?


Can you give us a bit more detail on the requirement? I'm not immediately clear on how qdepth would affect message routing - normally it's content.
I've seen more "interesting" ideas reading mqseries.net than I ever thought possible ...

anyways, if thats what you really want to do (and I agree with Vitor that its an unusual requirement), I had a long conversation with someone maybe 1 to 1-1/2 years ago here on writing and reading PCF messages from ESQL...if you search hard enough you'll find it ... good luck!
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
jefflowrey
PostPosted: Fri Dec 08, 2006 5:45 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It's not that hard to search for.
http://www.mqseries.net/phpBB2/viewtopic.php?t=23254
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wschutz
PostPosted: Fri Dec 08, 2006 5:48 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

jefflowrey wrote:
It's not that hard to search for.
http://www.mqseries.net/phpBB2/viewtopic.php?t=23254
not that hard for a "Grand Poobah"...
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
Vitor
PostPosted: Fri Dec 08, 2006 5:52 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

wschutz wrote:
jefflowrey wrote:
It's not that hard to search for.
http://www.mqseries.net/phpBB2/viewtopic.php?t=23254
not that hard for a "Grand Poobah"...


Nothing is hard for the Grand Poobah!!

Still trying to get my head round routing by queue depth though...
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kevinf2349
PostPosted: Fri Dec 08, 2006 6:07 am    Post subject: Reply with quote

Grand Master

Joined: 28 Feb 2003
Posts: 1311
Location: USA

Quote:
Still trying to get my head round routing by queue depth though...


Maybe it is for workload management/balancing?
Back to top
View user's profile Send private message
wschutz
PostPosted: Fri Dec 08, 2006 6:08 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Vitor wrote:
Still trying to get my head round routing by queue depth though...
Easy... if there are no messages, then don't route...if there are messages, then route them (sorry, maybe its the water here)
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ API Support » Check if queue is empty
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.