activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rolandpeng <rolandp...@cht.com.tw>
Subject UndeclaredThrowableException while calling getQueue() and removeQueue() at the same time(by use RemoteJMXBrokerFacade)
Date Mon, 18 Jun 2012 03:51:15 GMT
I'm trying to use org.apache.activemq.web.RemoteJMXBrokerFacade to preform
deleteQueue and getQueue.

The senario:
I have 100 queues(naming queue1~queue100) in broker,and the queue owner is
user1~user100 for each queue responding to the queue name.

let's say a situation below,
When user1 call remoteJMXBrokerFacade.getBrokerAdmin().getQueue("queue1"),
user2 delete "queue2" in the meantime.

This exception occrred.
==
java.lang.reflect.UndeclaredThrowableException
	at $Proxy57.getName(Unknown Source)
	at
org.apache.activemq.web.BrokerFacadeSupport.getDestinationByName(BrokerFacadeSupport.java:101)
at
org.apache.activemq.web.BrokerFacadeSupport.getQueue(BrokerFacadeSupport.java:89)
==

But this exception is not always happened. This exception only happens while
the  time between getQueue and deleteQueue called very close.
(I use activemq 5.5.1)

let me post the source code of BrokerFacadeSupport.getDestinationByName
--
    protected DestinationViewMBean getDestinationByName(Collection<? extends
DestinationViewMBean> collection,
            String name) {
        Iterator<? extends DestinationViewMBean> iter =
collection.iterator();
        while (iter.hasNext()) {
            DestinationViewMBean destinationViewMBean = iter.next();
            if (name.equals(destinationViewMBean.getName())) {
                return destinationViewMBean;
            }
        }
        return null;
    }
--
I think the key point of this exception is
"name.equals(destinationViewMBean.getName())".

While user1 call getQueue for queue1, the destinationViewMBean for queue2 is
no longer existed casue of  "queue2" has been deleted by user2.

It's not reasonable that user2 delete queue2, but user1 call
getQueue("queue1") receives exception.

so I write my own getQueue(String queueName) method to preventing from this
exception.
--

			JMXServiceURL url = new JMXServiceURL(
					Configuration.getPropertyAsString("JMX_SERVICE_URL"));
			JMXConnector jmxc = JMXConnectorFactory.connect(url);
			MBeanServerConnection conn = jmxc.getMBeanServerConnection();

			ObjectName objectNameRequest = new ObjectName(
					"org.apache.activemq:BrokerName=mqs,Type=Queue,Destination="
							+ queueName.replace("::", "__"));

			queueViewMbean = (QueueViewMBean) MBeanServerInvocationHandler
					.newProxyInstance(conn, objectNameRequest,
							QueueViewMBean.class, true);
--
Is it a bug in BrokerFacadeSupport.getDestinationByName()? Or I have another
way to get Queue via RemoteJMXBrokerFacade for recommendation? I prefer to
use JMX in activemq. Thank you.

--
View this message in context: http://activemq.2283324.n4.nabble.com/UndeclaredThrowableException-while-calling-getQueue-and-removeQueue-at-the-same-time-by-use-RemoteJM-tp4653342.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message