use of org.motechproject.admin.domain.TopicMBean in project motech by motech.
the class MBeanService method getTopicStatistics.
/**
* Returns topic statistics for the JMS topics.
*
* @return {@link List} of {@link TopicMBean}. One for each topic.
*/
@PreAuthorize(SecurityConstants.MANAGE_ACTIVEMQ)
public List<TopicMBean> getTopicStatistics() {
try {
List<TopicMBean> topics = new ArrayList<>();
for (ObjectName name : mBeanServer.getTopics()) {
String destination = name.getKeyProperty(mBeanServer.getDestinationProperty());
TopicViewMBean topicView = mBeanServer.getTopicViewMBean(name);
TopicMBean topic = new TopicMBean(destination);
topic.setEnqueueCount(topicView.getEnqueueCount());
topic.setDequeueCount(topicView.getDequeueCount());
topic.setExpiredCount(topicView.getExpiredCount());
topic.setConsumerCount(topicView.getConsumerCount());
topics.add(topic);
}
return topics;
} catch (IOException ex) {
throw new MotechException("Could not access MBeans ", ex);
}
}
use of org.motechproject.admin.domain.TopicMBean in project motech by motech.
the class BrokerStatisticsControllerTest method shouldReturnAllTopicInformation.
@Test
public void shouldReturnAllTopicInformation() throws Exception {
given(mBeanService.getTopicStatistics()).willReturn(Arrays.asList(new TopicMBean("topic-1"), new TopicMBean("topic-2")));
mockMvc.perform(MockMvcRequestBuilders.get("/topics")).andExpect(status().isOk()).andExpect(content().string(new StringContains("\"destination\":\"topic-1\""))).andExpect(content().string(new StringContains("\"destination\":\"topic-2\"")));
}
Aggregations