Author |
Message
|
arisco97 |
Posted: Fri Jun 25, 2004 1:33 pm Post subject: How to know the current debth of the receiving queue |
|
|
Newbie
Joined: 17 Sep 2002 Posts: 1
|
Hi,
Am not conversant much with JMS, but my team is using JMS. Is there a way in Java to inquire the current debth (i.e. actual number of messages waiting in the queue to be retrieved).
We need this for a re-active measure to manage incoming traffic and be able to send a message back to various senders to hold off sending more messages until we can get them off the queue.
Thanks |
|
Back to top |
|
 |
bower5932 |
Posted: Sat Jun 26, 2004 1:29 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
You can't get the current depth with JMS. If you to use the base MQ classes to have this ability. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Jun 26, 2004 5:31 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
As always there are two sides to the story.
Yes there is no way to directly get the QDepth in JMS.
There is however a workaround. It is slow and resource intensive but it will get the job done.
Create a QueueBrowser, retrieve the enumeration and count (call method getnextElement() ) until the method hasmoreElements returns false.
Usually nobody uses this in JMS because this method is too resource intensive and too costly....
Now you could write a wrap around for JMS but that will involve going back to MQ java and to do that you will need to cast your QueueConnectionFactory back to an MQQueueConnectionFactory, extract the properties, cast the JMS Queue to a JMS MQQueue extract the properties and then program the call in MQ java....
Too much work....
The option I would go for is to add the admin package to your program, create a pcf message requesting the currentQDepth and put it on the command server's input queue with a reply to jms destination. You will have to decode the response message...
If on os390 just use a plain text message runmqsc style to the input queue and specify the reply to queue.
F.J.  |
|
Back to top |
|
 |
bower5932 |
Posted: Sat Jun 26, 2004 8:51 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
I'd avoid the QueueBrowser and enumerate method. If your queue had a large number of messages, you'd basically be getting them simply to thrown them away so that you could get the count. There is no telling what kind of performance problems you'd end up with. |
|
Back to top |
|
 |
vennela |
Posted: Sat Jun 26, 2004 3:38 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Quote: |
We need this for a re-active measure to manage incoming traffic and be able to send a message back to various senders to hold off sending more messages until we can get them off the queue.
|
This has other solutions rather than using curdepth.
Can't we use performance events to get the job done? |
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Jun 26, 2004 3:57 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
vennela wrote: |
This has other solutions rather than using curdepth.
Can't we use performance events to get the job done? |
Yes, I'm sure this can be done.
In addition, I don't personally think it is a good idea (for a few reasons) to include this kind of monitoring in a business application. Self-monitoring is only as good as the app itself...
It's much better for the architecture, reliability, and maintenance of an application to keep it tightly focused on only those things it's supposed to be doing. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
balaji sr |
Posted: Mon Jun 28, 2004 3:38 am Post subject: |
|
|
Apprentice
Joined: 07 Jan 2003 Posts: 28
|
I am not sure how to implement this in JMS. But this can be done in Java - MQSeries using MQInquiry
If you are interested in this apporach, you can get the sample code from
http://java.ittoolbox.com/code/d.asp?i=8&a=c and look for mqInquiry java sample code...... |
|
Back to top |
|
 |
|