You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Andruil <cu...@hotmail.com> on 2008/09/09 19:32:34 UTC

DestinationStatistics

I'm trying to figure out how to get the JMS statistics mentioned 
http://www.infoq.com/news/2008/05/activemq-5.1-release here  but I'm running
around in circles trying to figure out how to access it.  As far as I can
tell the info I want is located in the DestinationStatistics class but I
cannot figure out how to get it populated.

It seems to me that I need a broker.region.Destination but so far all I can
seem to find is a javax.jms.Destination from the ActiveMQQueue.

Sigh I know what I want (Statistics / Queue Statistics) and I know it is
possible but I am more than a bit lost as to how to get those statistics. 
Any help would be appreciated.
-- 
View this message in context: http://www.nabble.com/DestinationStatistics-tp19397314p19397314.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: DestinationStatistics

Posted by Andruil <cu...@hotmail.com>.


bsnyder wrote:
> 
> On Tue, Sep 9, 2008 at 11:32 AM, Andruil <cu...@hotmail.com>
> wrote:
>>
>> I'm trying to figure out how to get the JMS statistics mentioned
>> http://www.infoq.com/news/2008/05/activemq-5.1-release here  but I'm
>> running
>> around in circles trying to figure out how to access it.  As far as I can
>> tell the info I want is located in the DestinationStatistics class but I
>> cannot figure out how to get it populated.
>>
>> It seems to me that I need a broker.region.Destination but so far all I
>> can
>> seem to find is a javax.jms.Destination from the ActiveMQQueue.
>>
>> Sigh I know what I want (Statistics / Queue Statistics) and I know it is
>> possible but I am more than a bit lost as to how to get those statistics.
>> Any help would be appreciated.
> 
> These statistics are published via the JMX instrumentation. You can
> view them using any JMX tool like Jconsole or you can access them
> programmatically using the JMX APIs. I've published an example of how
> to use the JMX APIs here:
> 
> http://markmail.org/search/?q=amqjmxexampletest.java#query:amqjmxexampletest.java+page:1+mid:us7q7dgdinp2sfo6+state:results
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> 
> Blog: http://bruceblog.org/
> 
> 


Thank you for your help.  I'll take a deeper look into this.
-- 
View this message in context: http://www.nabble.com/DestinationStatistics-tp19397314p19397773.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: DestinationStatistics

Posted by Bruce Snyder <br...@gmail.com>.
On Tue, Sep 9, 2008 at 11:32 AM, Andruil <cu...@hotmail.com> wrote:
>
> I'm trying to figure out how to get the JMS statistics mentioned
> http://www.infoq.com/news/2008/05/activemq-5.1-release here  but I'm running
> around in circles trying to figure out how to access it.  As far as I can
> tell the info I want is located in the DestinationStatistics class but I
> cannot figure out how to get it populated.
>
> It seems to me that I need a broker.region.Destination but so far all I can
> seem to find is a javax.jms.Destination from the ActiveMQQueue.
>
> Sigh I know what I want (Statistics / Queue Statistics) and I know it is
> possible but I am more than a bit lost as to how to get those statistics.
> Any help would be appreciated.

These statistics are published via the JMX instrumentation. You can
view them using any JMX tool like Jconsole or you can access them
programmatically using the JMX APIs. I've published an example of how
to use the JMX APIs here:

http://markmail.org/search/?q=amqjmxexampletest.java#query:amqjmxexampletest.java+page:1+mid:us7q7dgdinp2sfo6+state:results

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/

Blog: http://bruceblog.org/

Re: DestinationStatistics

Posted by Andruil <cu...@hotmail.com>.


Mario Siegenthaler-2 wrote:
> 
> IIRC you should use a MBeanServerConnection and then
> getAttribute(objectName, "enqueueCount") on it to get the value you're
> looking for.
> I you're surfing around on "reflection"-level, you get all the
> information ABOUT the mbean, but not the actual mbean.
> 
> --Mario
> 

That did the trick.  I never even thought that I'd have to re-request for
the attribute name.


Thank all of you for your help.  I couldn't have done it without you.
-- 
View this message in context: http://www.nabble.com/DestinationStatistics-tp19397314p19422755.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: DestinationStatistics

Posted by Mario Siegenthaler <ms...@inventsoft.ch>.
IIRC you should use a MBeanServerConnection and then
getAttribute(objectName, "enqueueCount") on it to get the value you're
looking for.
I you're surfing around on "reflection"-level, you get all the
information ABOUT the mbean, but not the actual mbean.

--Mario

On Wed, Sep 10, 2008 at 10:28 PM, Andruil <cu...@hotmail.com> wrote:
>
> I'm so close that it is driving me nuts.
>
> After a bit of reading and experimenting what I've come up with is
>
> MBeanInfo mbi = getMBeanInfo(connection, new
> ObjectName("org.apache.activemq:BrokerName=localhost,Type=Queue,Destination=NewQueue"));
>
> for(MBeanAttributeInfo mbai : mbi.getAttributes())
> {
>
>        log.info("Name: " + mbai.getName() + ", Description: " +
> mbai.getDescription());
>        Descriptor d = mbai.getDescriptor();
>
>        for(String s : d.getFieldNames())
>        {
>                log.info("Name: " + s + ", Value: " + d.getFieldValue(s));
>        }
> }
>
>
> But for each of the MBeanAttributeInfos the getFieldNames returns an empty
> list.  From the names of the attributes this looks to be what I want
> (EnqueueCount, DequeueCount, etc).  Am I missing a step to retrieve the
> values?
>
> --
> View this message in context: http://www.nabble.com/DestinationStatistics-tp19397314p19422502.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>
>

Re: DestinationStatistics

Posted by Andruil <cu...@hotmail.com>.
I'm so close that it is driving me nuts.

After a bit of reading and experimenting what I've come up with is 

MBeanInfo mbi = getMBeanInfo(connection, new
ObjectName("org.apache.activemq:BrokerName=localhost,Type=Queue,Destination=NewQueue"));

for(MBeanAttributeInfo mbai : mbi.getAttributes())
{

	log.info("Name: " + mbai.getName() + ", Description: " +
mbai.getDescription());
	Descriptor d = mbai.getDescriptor();

	for(String s : d.getFieldNames())
	{
		log.info("Name: " + s + ", Value: " + d.getFieldValue(s));
	}
}


But for each of the MBeanAttributeInfos the getFieldNames returns an empty
list.  From the names of the attributes this looks to be what I want
(EnqueueCount, DequeueCount, etc).  Am I missing a step to retrieve the
values?
 
-- 
View this message in context: http://www.nabble.com/DestinationStatistics-tp19397314p19422502.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: DestinationStatistics

Posted by James Strachan <ja...@gmail.com>.
2008/9/10 Andruil <cu...@hotmail.com>:
>
>
>
> 2008/9/10 Andruil <cu...@hotmail.com>:
>
> Have you read the JMX information describing the available mbeans and
> their object names etc?
> http://activemq.apache.org/jmx.html
>
>
> I have read through them but I don't understand how to create them.  Is
> there any tutorials on how to create a Destination MBean?

You don't create them, you look them up in JMX. Maybe start here?
http://java.sun.com/developer/technicalArticles/J2SE/jmx.html

> One other thing I don't quite understand is what the broker is for.

Its the ActiveMQ message broker - the server which routes messages around.

You don't create any of the JMX MBeans - you just look them up. Start
by using JConsole to connect to the broker's JVM and browsing around -
before you try writing any Java code.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: DestinationStatistics

Posted by Andruil <cu...@hotmail.com>.


2008/9/10 Andruil <cu...@hotmail.com>:

Have you read the JMX information describing the available mbeans and
their object names etc?
http://activemq.apache.org/jmx.html


I have read through them but I don't understand how to create them.  Is
there any tutorials on how to create a Destination MBean?  I've been
spending quite a bit of time researching this and I haven't quite figured
out how to create a Destination that gives me what I'm looking for.

Just to confirm we are both refering to the broker.region.Destination
correct?

One other thing I don't quite understand is what the broker is for.  As near
as I can tell it is used on the server where ActiveMQ is running and not on
a local machine trying to connect to the broker.  Is that correct?  

All my attempts to use
http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html
to connect to a remote machine have met with frustration.


Thank you for you help.  It is greatly appreciated.

-- 
View this message in context: http://www.nabble.com/DestinationStatistics-tp19397314p19420557.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: DestinationStatistics

Posted by James Strachan <ja...@gmail.com>.
2008/9/10 Andruil <cu...@hotmail.com>:
>
> I've been playing around with the example that you provided bsnyder.  I
> initially had a problem with the default ActiveMQ configuration not
> accepting connections (even JConsole wouldn't work) but I've gotten that
> resolved.  Now I'm wondering where do I look for attribute information?  I
> have been looking through the getMBeanInfo results and it seems to mention
> the information I'm looking for but I cannot figure out how to get a
> specific value.  I went through the field names but each attribute has 0
> fields.
>
> How do I get the queue size and such now that I have the JMX working.

Have you read the JMX information describing the available mbeans and
their object names etc?
http://activemq.apache.org/jmx.html


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: DestinationStatistics

Posted by Andruil <cu...@hotmail.com>.
I've been playing around with the example that you provided bsnyder.  I
initially had a problem with the default ActiveMQ configuration not
accepting connections (even JConsole wouldn't work) but I've gotten that
resolved.  Now I'm wondering where do I look for attribute information?  I
have been looking through the getMBeanInfo results and it seems to mention
the information I'm looking for but I cannot figure out how to get a
specific value.  I went through the field names but each attribute has 0
fields.  

How do I get the queue size and such now that I have the JMX working.
-- 
View this message in context: http://www.nabble.com/DestinationStatistics-tp19397314p19414661.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: DestinationStatistics

Posted by Andruil <cu...@hotmail.com>.
I went back and revisited
http://www.infoq.com/news/2008/05/activemq-5.1-release and am a bit confused
now.  According to it they've added in an API for viewing JMS statistics.

InfoQ wrote:
> There is a new API to help end users view available destinations and query
> them to find JMS statistics such as active queue count, queue depth,
> number of messages etc. 

How does this tie in with the JMX?

Just to clarify I am trying to get the statistics in a java program.  We can
already use the web method of getting statistics but the desire is to
incorporate those statistics into our program.
-- 
View this message in context: http://www.nabble.com/DestinationStatistics-tp19397314p19398978.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: DestinationStatistics

Posted by James Strachan <ja...@gmail.com>.
2008/9/9 Andruil <cu...@hotmail.com>:
>
> I'm trying to figure out how to get the JMS statistics mentioned
> http://www.infoq.com/news/2008/05/activemq-5.1-release here  but I'm running
> around in circles trying to figure out how to access it.

As Bruce said, you can try JMX or jconsole. Or you can click on this link

http://localhost:8161/admin/queues.jsp

to browse the core queue stats via the Web Console
http://activemq.apache.org/web-console.html

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com