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.

Reply via email to