You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by bansalp <bp...@gmail.com> on 2014/11/13 15:23:39 UTC
Get Number of connection from all host to my activemq broker.
Hi,
ActiveMQ broker setup:
broker is running on machine: hostA
Clients from different host can connect to my broker instance running on
hostA, there can be any number of client from any host.
Is there a way to find out how many clients are connected to broker and also
list which tell me how many connection from each host is there to my broker.
I want to do this without making assumption about number of hosts.
I can do this by using lsof command and some parsing over output, but I am
in situation where I can not use this.
Is there any feature provided by ActiveMQ command line utility
*activemq-admin*.
Thanks,
--bansalp
--
View this message in context: http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Get Number of connection from all host to my activemq broker.
Posted by bansalp <bp...@gmail.com>.
Can you please guide me on how can this be achieved using JMX api. (for now
lets forget whether values are right or wrong).
Thanks,
--bansalp
--
View this message in context: http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405p4687430.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Get Number of connection from all host to my activemq broker.
Posted by Tim Bain <tb...@alumni.duke.edu>.
Right, that's why I said that I'm not sure you'll be able to do this using
the activemq-admin console (though maybe someone else will know of a way),
and that I believe that it can be done using the Java JMX MBeans API plus
some custom Java code to group/count the results. But as I said, I've seen
some results in JMX under 5.8.0 that don't appear to match reality (or I'm
misunderstanding what "clientConnectors" actually means), so it may take
some work on your part to get it right (or you might find a bug that needs
to be fixed for it to work right).
On Thu, Nov 13, 2014 at 10:04 AM, bansalp <bp...@gmail.com> wrote:
> I can get currentConnection count using activemq-admin query --view
> CurrentConnectionsCount jmxurl.......
>
> But I want number of client from each host as well.
>
>
> Thanks,
> --bansalp
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405p4687416.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Re: Get Number of connection from all host to my activemq broker.
Posted by artnaseef <ar...@artnaseef.com>.
JMX has all the information needed.
Another approach - outside the JVM - netstat.
Something like this may work:
netstat -an | grep 61616
Then use awk or the like to pull out the remote (client) IP address and then
sort | uniq -c to get the counts.
--
View this message in context: http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405p4687776.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Get Number of connection from all host to my activemq broker.
Posted by bansalp <bp...@gmail.com>.
Thanks Tim, This is really resourceful, I will try this.
Thanks,
--bansalp
--
View this message in context: http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405p4687459.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Get Number of connection from all host to my activemq broker.
Posted by Tim Bain <tb...@alumni.duke.edu>.
Configure the broker to expose JMX status (
http://activemq.apache.org/jmx.html), if you haven't already done so. Then
make sure you understand what's in the JMX beans; an easy way to do that is
to attach JConsole to the broker and navigate through the MBeans tab. Once
you've done this, you should have a good idea of the algorithm you want to
use to actually gather up those beans, and all you should have questions
about is how to actually get them programmatically. (If you've still got
questions about the algorithm you want to use, you need to figure that out
before you go any further.)
In your code, establish a connection to it (
http://java.dzone.com/articles/managing-activemq-jmx-apis). Once you're
connected, you can get access to various MBean classes that correspond to
the different elements in the JMX tree you browsed in JConsole; the name of
the class is generally the name of the JMX element with "ViewMBean"
appended to it, such as BrokerViewMBean, ConnectionViewMBean, etc.
To get a set of MBean elements of a given type, you need to build a search
string, which is essentially the path you want to walk down the MBeans tree
you viewed in JConsole. It will probably start with
"org.apache.activemq:type=Broker,brokerName=YOURBROKERNAME," and then will
continue from there (maybe you'll want to use "connector=clientConnectors"
to drill further, for example). The things you can query for are
documented in the ActiveMQ JMX page I linked in the first paragraph.
That should be enough to put you on the right path, but I'll give you a
word of warning for two things I learned the hard way:
1) The query format changed in 5.8.0 (as documented on the ActiveMQ JMX
page), and a lot of the blog posts that gave examples were using the
earlier format because they were written before 5.8.0 came out and don't
call out that they're using a format that's no longer applicable. The
formats are pretty similar (and easy enough to translate between once you
realize there's a difference), but be aware if you look at older blog posts
that the query may not work if you just copy-and-paste.
2) If I remember correctly, the query format is case-sensitive (and I
believe that one of the things that changed in 5.8.0 is capitalization of
some parts of the query), which can lead to frustration if you weren't
expecting it to matter.
Good luck.
Tim
On Fri, Nov 14, 2014 at 2:37 AM, Andreas Gies <an...@wayofquality.de>
wrote:
> Hi
>
> if you want a view by host, you have to iterate over the Client Connection
> MBeans and group by the client’s address.
>
> Best regards
> Andreas
>
> > On 13 Nov 2014, at 18:04, bansalp <bp...@gmail.com> wrote:
> >
> > I can get currentConnection count using activemq-admin query --view
> > CurrentConnectionsCount jmxurl.......
> >
> > But I want number of client from each host as well.
> >
> >
> > Thanks,
> > --bansalp
> >
> >
> >
> > --
> > View this message in context:
> http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405p4687416.html
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
Re: Get Number of connection from all host to my activemq broker.
Posted by Andreas Gies <an...@wayofquality.de>.
Hi
if you want a view by host, you have to iterate over the Client Connection MBeans and group by the client’s address.
Best regards
Andreas
> On 13 Nov 2014, at 18:04, bansalp <bp...@gmail.com> wrote:
>
> I can get currentConnection count using activemq-admin query --view
> CurrentConnectionsCount jmxurl.......
>
> But I want number of client from each host as well.
>
>
> Thanks,
> --bansalp
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405p4687416.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Get Number of connection from all host to my activemq broker.
Posted by bansalp <bp...@gmail.com>.
I can get currentConnection count using activemq-admin query --view
CurrentConnectionsCount jmxurl.......
But I want number of client from each host as well.
Thanks,
--bansalp
--
View this message in context: http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405p4687416.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Get Number of connection from all host to my activemq broker.
Posted by Andreas Gies <an...@wayofquality.de>.
Hi Tim,
AFAIK, the ClientConnectors are the actual server ports whereas the ClientConnections
are the currently connected clients.
Best regards
Andreas
> On 13 Nov 2014, at 17:28, Tim Bain <tb...@alumni.duke.edu> wrote:
>
> Looking at the documentation for activemq-admin (
> http://activemq.apache.org/activemq-command-line-tools-reference.html), I
> don't see a way to get this information without using JMX, but maybe
> someone knows of a way to do it.
>
> If you can't find a way to do this via activemq-admin, you should be able
> to do it using the JMX interface, though I've found (in 5.8.0) that the
> number of client connections reported in JMX under clientConnectors is
> vastly larger than the number reported in the web console, and I haven't
> yet found an explanation for the difference. (Or maybe I'm
> misunderstanding some subtle difference between a client connector and a
> client connection?)
>
> Tim
>
> On Thu, Nov 13, 2014 at 7:23 AM, bansalp <bp...@gmail.com> wrote:
>
>> Hi,
>>
>> ActiveMQ broker setup:
>>
>> broker is running on machine: hostA
>>
>> Clients from different host can connect to my broker instance running on
>> hostA, there can be any number of client from any host.
>>
>> Is there a way to find out how many clients are connected to broker and
>> also
>> list which tell me how many connection from each host is there to my
>> broker.
>>
>> I want to do this without making assumption about number of hosts.
>>
>> I can do this by using lsof command and some parsing over output, but I am
>> in situation where I can not use this.
>>
>> Is there any feature provided by ActiveMQ command line utility
>> *activemq-admin*.
>>
>> Thanks,
>> --bansalp
>>
>>
>>
>> --
>> View this message in context:
>> http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
Re: Get Number of connection from all host to my activemq broker.
Posted by Tim Bain <tb...@alumni.duke.edu>.
Looking at the documentation for activemq-admin (
http://activemq.apache.org/activemq-command-line-tools-reference.html), I
don't see a way to get this information without using JMX, but maybe
someone knows of a way to do it.
If you can't find a way to do this via activemq-admin, you should be able
to do it using the JMX interface, though I've found (in 5.8.0) that the
number of client connections reported in JMX under clientConnectors is
vastly larger than the number reported in the web console, and I haven't
yet found an explanation for the difference. (Or maybe I'm
misunderstanding some subtle difference between a client connector and a
client connection?)
Tim
On Thu, Nov 13, 2014 at 7:23 AM, bansalp <bp...@gmail.com> wrote:
> Hi,
>
> ActiveMQ broker setup:
>
> broker is running on machine: hostA
>
> Clients from different host can connect to my broker instance running on
> hostA, there can be any number of client from any host.
>
> Is there a way to find out how many clients are connected to broker and
> also
> list which tell me how many connection from each host is there to my
> broker.
>
> I want to do this without making assumption about number of hosts.
>
> I can do this by using lsof command and some parsing over output, but I am
> in situation where I can not use this.
>
> Is there any feature provided by ActiveMQ command line utility
> *activemq-admin*.
>
> Thanks,
> --bansalp
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Get-Number-of-connection-from-all-host-to-my-activemq-broker-tp4687405.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>