mirror of https://github.com/apache/activemq.git
added a more jolokia friendly statusList() method which returns nicer JSON for the status query
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1415594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fc706d074a
commit
3cf129a79f
|
@ -22,6 +22,8 @@ import javax.management.openmbean.CompositeType;
|
|||
import javax.management.openmbean.TabularData;
|
||||
import javax.management.openmbean.TabularDataSupport;
|
||||
import javax.management.openmbean.TabularType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StatusView implements StatusViewMBean {
|
||||
|
@ -39,14 +41,24 @@ public class StatusView implements StatusViewMBean {
|
|||
TabularType tt = new TabularType("Status", "Status", ct, new String[]{"id", "resource"});
|
||||
TabularDataSupport rc = new TabularDataSupport(tt);
|
||||
|
||||
Map<ObjectName, DestinationView> queueViews = broker.getQueueViews();
|
||||
for (Map.Entry<ObjectName, DestinationView> entry : queueViews.entrySet()) {
|
||||
DestinationView queue = entry.getValue();
|
||||
if (queue.getConsumerCount() == 0 && queue.getProducerCount() > 0) {
|
||||
rc.put(new CompositeDataSupport(ct, factory.getFields(new StatusEvent("AMQ-NoConsumer", entry.getKey().toString()))));
|
||||
}
|
||||
List<StatusEvent> list = statusList();
|
||||
for (StatusEvent statusEvent : list) {
|
||||
rc.put(new CompositeDataSupport(ct, factory.getFields(statusEvent)));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StatusEvent> statusList() throws Exception {
|
||||
List<StatusEvent> answer = new ArrayList<StatusEvent>();
|
||||
Map<ObjectName, DestinationView> queueViews = broker.getQueueViews();
|
||||
for (Map.Entry<ObjectName, DestinationView> entry : queueViews.entrySet()) {
|
||||
DestinationView queue = entry.getValue();
|
||||
if (queue.getConsumerCount() == 0 && queue.getProducerCount() > 0) {
|
||||
answer.add(new StatusEvent("AMQ-NoConsumer", entry.getKey().toString()));
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,21 @@
|
|||
package org.apache.activemq.broker.jmx;
|
||||
|
||||
import javax.management.openmbean.TabularData;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Returns the status events of the broker to indicate any warnings.
|
||||
*/
|
||||
public interface StatusViewMBean {
|
||||
|
||||
public TabularData status() throws Exception;
|
||||
|
||||
/**
|
||||
* Warning this method can only be invoked if you have the correct version
|
||||
* of {@link StatusEvent} on your classpath or you use something
|
||||
* like <a href="http://jolokia.org/">jolokia</a> to access JMX.
|
||||
*
|
||||
* If in doubt, please use the {@link #status()} method instead!
|
||||
*/
|
||||
List<StatusEvent> statusList() throws Exception;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue