}
ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=TEST");
LOG.info("Create QueueView MBean...");
QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
long concount = proxy.getConsumerCount();
LOG.info("Consumer Count :" + concount);
long messcount = proxy.getQueueSize();
LOG.info("current number of messages in the queue :" + messcount);
// lets browse
CompositeData[] compdatalist = proxy.browse();
if (compdatalist.length == 0) {
fail("There is no message in the queue:");
}
String[] messageIDs = new String[compdatalist.length];
for (int i = 0; i < compdatalist.length; i++) {
CompositeData cdata = compdatalist[i];
if (i == 0) {
LOG.info("Columns: " + cdata.getCompositeType().keySet());
}
messageIDs[i] = (String)cdata.get("JMSMessageID");
LOG.info("message " + i + " : " + cdata.values());
}
TabularData table = proxy.browseAsTable();
LOG.info("Found tabular data: " + table);
assertTrue("Table should not be empty!", table.size() > 0);
assertEquals("Queue size", outbound.length, proxy.getQueueSize());
assertEquals("Queue size", outbound.length, compdatalist.length);
assertEquals("Queue size", outbound.length, table.size());
LOG.info("Send another 10");
for (int i=0;i<outbound.length; i++) {
producer.send(outbound[i]);
}
LOG.info("Browse again");
messcount = proxy.getQueueSize();
LOG.info("current number of messages in the queue :" + messcount);
compdatalist = proxy.browse();
if (compdatalist.length == 0) {
fail("There is no message in the queue:");
}
messageIDs = new String[compdatalist.length];
for (int i = 0; i < compdatalist.length; i++) {
CompositeData cdata = compdatalist[i];
if (i == 0) {
LOG.info("Columns: " + cdata.getCompositeType().keySet());
}
messageIDs[i] = (String)cdata.get("JMSMessageID");
LOG.info("message " + i + " : " + cdata.values());
}
table = proxy.browseAsTable();
LOG.info("Found tabular data: " + table);
assertTrue("Table should not be empty!", table.size() > 0);
assertEquals("Queue size", outbound.length*2, proxy.getQueueSize());
assertEquals("Queue size", outbound.length*2, compdatalist.length);
assertEquals("Queue size", outbound.length * 2, table.size());
consumer = session.createConsumer(destination);
for (int i=0; i<outbound.length * 2; i++) {