问题
I am facing a pretty common error, but still haven't found a solution for it. I am using async message sending:
Queue adminQueue=session.createQueue("admin_queue");
MessageConsumer mc=session.createConsumer(adminQueue);
mc.setMessageListener(new AdminListener(emfMaster,ps));
connection.start();
this.statisticProvider = new AdminStats(adminQueue, mc, session);
And I need to receive statstics for it, using a Stat Plugin for ActiveMQ, which is stuffed into my AdminStats class(it starts a new thread for receiving stats), but still it tells, that I can use only sync message sending, not specifying the MessageListener.
[javax.jms.IllegalStateException: Cannot synchronously receive a message when a MessageListener is set]
I have no right to change the way messages are sent. Is there any way to get the stats in async way?
回答1:
You can get stats using JMX. Or with advisory messages. Some links from here: http://activemq.apache.org/how-can-i-monitor-activemq.html
来源:https://stackoverflow.com/questions/12937705/activemq-async-statistics-receiving