look at org.apache.activemq.ActiveMQConnection#getResourceManagerId or org.apache.activemq.ActiveMQConnection#getBrokerName
you can cast your QueueConnection to ActiveMQConnection On 24 February 2012 06:45, archa <archa_bhand...@persistent.co.in> wrote: > The message broker used in my application has the failover protocol used over > 2 brokers. > While creating the consumer, I need to know on which broker the actual > consumer was formed. i.e I want to fetch at runtime the the current master > IP/Hostname > While debugging, I saw that the QueueConnection object (conn) acquired, has > the info in the 'brokerInfo' parameter in the QueueConnection object. But > there is no api in the QueueConnection class using which I can get the > required info. > > Can someone point me to the api using which I can get this info. > > My code: > > Properties props1 = new Properties(); > props1.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory"); > props1.setProperty(Context.PROVIDER_URL, > "failover:(tcp://<broker1>:61616,tcp://<broker2>:61616)?randomize=false"); > props1.setProperty("queue.queue1", "wdp.queue1"); > > Context ctx = new InitialContext(props1); > QueueConnectionFactory qFactory = (QueueConnectionFactory) > ctx.lookup("QueueConnectionFactory"); > > QueueConnection conn = qFactory.createQueueConnection(); > > final QueueSession session = > conn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE); > > Queue queue = (Queue) ctx.lookup("queue1"); > > ActiveMQQueueReceiver receiver = (ActiveMQQueueReceiver) > session.createReceiver(queue); > > receiver.setAvailableListener(this); > > conn.start(); > > -- > View this message in context: > http://activemq.2283324.n4.nabble.com/Trying-the-read-the-current-master-at-runtime-tp4416344p4416344.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. -- http://fusesource.com http://blog.garytully.com