I needed to find the master broker similarly, for our resiliency testing -
you can call connection.getBrokerInfo() (you might have to cast the
connection to ActiveMQConnection if you just have a JMS Connection object),
and then that exposes a pile of information like getBrokerURL() and
isMaster().

http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnection.html#getBrokerInfo()


Mind you, I haven't tried this in a failover situation yet - I just use it
to verify the master broker when I start my tests, I don't use it to try to
tell if I've switched to a slave.  But it should work.

As for getting queue depth, I think you can also use
session.createBrowser(queue) to create a QueueBrowser, that can then
enumerate all the messages on the queue without consuming them.  Not sure
how expensive that is, presumably for a big queue using JMX would be much
faster; also of course the queue depth might give strange results when
there are transactions and writes and reads also happening.

- Korny

On 20 July 2016 at 09:36, khandelwalanuj <anuj.cool.khandel...@gmail.com>
wrote:

> Problem with JMX is I can't specify failover url :
> "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi"
>
> I am using master slave topology and I don't know which broker is master
> and
> which is slave at any point of time, So I have to maintain the list of
> broker URLs and keep trying until connection is successful which is a lot
> to
> do just to get the Queue Size.
>
> I was wondering if there should be an easy API in ActiveMQ to get since
> this
> is a very basic requirement.
>
> Thanks,
> Anuj
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Queue-size-from-client-side-tp4714102p4714149.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
Kornelis Sietsma  korny at my surname dot com http://korny.info
.fnord { display: none !important; }

Reply via email to