use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.
the class JMXRemoveQueueThenSendIgnoredTest method numberOfMessages.
private int numberOfMessages() throws Exception {
ObjectName queueViewMBeanName = new ObjectName(domain + ":destinationType=Queue,destinationName=myqueue,type=Broker,brokerName=dev");
QueueViewMBean queue = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
long size = queue.getQueueSize();
return (int) size;
}
use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.
the class ConsumeUncompressedCompressedMessageTest method getProxyToQueueViewMBean.
private QueueViewMBean getProxyToQueueViewMBean() throws MalformedObjectNameException, JMSException {
ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq" + ":destinationType=Queue,destinationName=" + queue.getQueueName() + ",type=Broker,brokerName=localhost");
QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
return proxy;
}
use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.
the class QueuePurgeTest method testPurgeLargeQueue.
public void testPurgeLargeQueue() throws Exception {
applyBrokerSpoolingPolicy();
createProducerAndSendMessages(NUM_TO_SEND);
QueueViewMBean proxy = getProxyToQueueViewMBean();
LOG.info("purging..");
org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(org.apache.activemq.broker.region.Queue.class);
final AtomicBoolean gotPurgeLogMessage = new AtomicBoolean(false);
Appender appender = new DefaultTestAppender() {
@Override
public void doAppend(LoggingEvent event) {
if (event.getMessage() instanceof String) {
String message = (String) event.getMessage();
if (message.contains("purged of " + NUM_TO_SEND + " messages")) {
LOG.info("Received a log message: {} ", event.getMessage());
gotPurgeLogMessage.set(true);
}
}
}
};
Level level = log4jLogger.getLevel();
log4jLogger.setLevel(Level.INFO);
log4jLogger.addAppender(appender);
try {
proxy.purge();
} finally {
log4jLogger.setLevel(level);
log4jLogger.removeAppender(appender);
}
assertEquals("Queue size is not zero, it's " + proxy.getQueueSize(), 0, proxy.getQueueSize());
assertTrue("cache is disabled, temp store being used", !proxy.isCacheEnabled());
assertTrue("got expected info purge log message", gotPurgeLogMessage.get());
}
use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.
the class PurgeCommandTest method testQueueViewMbean.
/**
* This test ensures that the queueViewMbean will work.
*
* @throws Exception
*/
public void testQueueViewMbean() throws Exception {
try {
addMessages();
validateCounts(MESSAGE_COUNT, MESSAGE_COUNT, MESSAGE_COUNT * 2);
List<String> tokens = Arrays.asList(new String[] { "*" });
for (String token : tokens) {
List<ObjectInstance> queueList = JmxMBeansUtil.queryMBeans(createJmxConnection(), "type=Broker,brokerName=localbroker,destinationType=Queue,destinationName=" + token);
for (ObjectInstance queue : queueList) {
ObjectName queueName = queue.getObjectName();
QueueViewMBean proxy = MBeanServerInvocationHandler.newProxyInstance(createJmxConnection(), queueName, QueueViewMBean.class, true);
int removed = proxy.removeMatchingMessages(MSG_SEL_WITH_PROPERTY);
LOG.info("Removed: " + removed);
}
}
validateCounts(0, MESSAGE_COUNT, MESSAGE_COUNT);
} finally {
purgeAllMessages();
}
}
use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.
the class SecurityJMXTest method testMoveMessages.
public void testMoveMessages() throws Exception {
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
JMXConnector connector = JMXConnectorFactory.connect(url, null);
connector.connect();
MBeanServerConnection connection = connector.getMBeanServerConnection();
ObjectName name = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost," + "destinationType=Queue,destinationName=TEST.Q");
QueueViewMBean queueMbean = MBeanServerInvocationHandler.newProxyInstance(connection, name, QueueViewMBean.class, true);
String msgId = queueMbean.sendTextMessage("test", "system", "manager");
queueMbean.moveMessageTo(msgId, "TEST1.Q");
}
Aggregations