You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by hardtolose <ho...@gmail.com> on 2008/08/06 11:00:18 UTC

How can I get all the connections to the Broker?

I need the connection to get the client's "connectionID" and "remote
Address"..

Can anybody tell me how to solve this problem? 
-- 
View this message in context: http://www.nabble.com/How-can-I-get-all-the-connections-to-the-Broker--tp18846998p18846998.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How can I get all the connections to the Broker?

Posted by hardtolose <ho...@gmail.com>.

Yes, thank you.. I have been solved this problem..

Use this way: 

ObjectName conName = new
ObjectName("org.apache.activemq:BrokerName=localhost,Type=Connection,*");
Set connections = connection.queryNames(conName, null);

can get all the connections to the Broker, and then use ConnectionViewMBean
can get what I need..

code: 

            Object[] c = connections.toArray();
            for(int s=0;s<c.length;s++)
            {
            	ObjectName con = (ObjectName)c[s];
            	System.out.println(con.toString());
            	String conStr = con.getKeyProperty("Connection");
            	if(conStr!=null)
            	{
	            	String ID = conStr.replaceAll("_", ":");
	            	System.out.println(conStr);
	            	ConnectionViewMBean connectionView = (ConnectionViewMBean)
MBeanServerInvocationHandler.newProxyInstance(
	            			connection, con, ConnectionViewMBean.class, true);
	            	
	            	String address = connectionView.getRemoteAddress();
	            	System.out.println(ID+", "+address);
            	}
            }

Thank you all ^_^.


ABV wrote:
> 
> Maybe you can use JMX?
> 
> 
> hardtolose wrote:
>> 
>> Hi, everybody..
>> 
>> I need the connection to get the client's "connectionID" and "remote
>> Address"..
>> 
>> Can anybody tell me how to solve this problem? 
>> 
>> Not use local Embedded Broker, but use remote Broker..Many thanks in
>> advance!
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-can-I-get-all-the-connections-to-the-Broker--tp18846998p18983370.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How can I get all the connections to the Broker?

Posted by ABV <bo...@inbox.lv>.
Maybe you can use JMX?


hardtolose wrote:
> 
> Hi, everybody..
> 
> I need the connection to get the client's "connectionID" and "remote
> Address"..
> 
> Can anybody tell me how to solve this problem? 
> 
> Not use local Embedded Broker, but use remote Broker..Many thanks in
> advance!
> 

-- 
View this message in context: http://www.nabble.com/How-can-I-get-all-the-connections-to-the-Broker--tp18846998p18981036.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.