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?
You can get stats using JMX. Or with advisory messages. Some links from here: http://activemq.apache.org/how-can-i-monitor-activemq.html