Search in sources :

Example 6 with QueueViewMBean

use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.

the class QueuePurgeTest method getProxyToQueueViewMBean.

private QueueViewMBean getProxyToQueueViewMBean() throws MalformedObjectNameException, JMSException {
    ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + queue.getQueueName());
    QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
    return proxy;
}
Also used : QueueViewMBean(org.apache.activemq.broker.jmx.QueueViewMBean) ObjectName(javax.management.ObjectName)

Example 7 with QueueViewMBean

use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.

the class BrowseDLQTest method assertCanBrowse.

private void assertCanBrowse() throws MalformedObjectNameException, OpenDataException {
    ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=ActiveMQ.DLQ");
    QueueViewMBean queue = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
    // make sure we have messages here
    assertTrue(queue.getQueueSize() > 0);
    CompositeData[] regularBrowse = queue.browse();
    assertNotNull(regularBrowse);
    TabularData tableData = queue.browseAsTable();
    assertNotNull(tableData);
}
Also used : CompositeData(javax.management.openmbean.CompositeData) QueueViewMBean(org.apache.activemq.broker.jmx.QueueViewMBean) ObjectName(javax.management.ObjectName) TabularData(javax.management.openmbean.TabularData)

Example 8 with QueueViewMBean

use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.

the class ConsumeUncompressedCompressedMessageTest method testBrowseAndReceiveCompressedMessages.

@Test
public void testBrowseAndReceiveCompressedMessages() throws Exception {
    assertTrue(connection.isUseCompression());
    createProducerAndSendMessages(1);
    QueueViewMBean queueView = getProxyToQueueViewMBean();
    assertNotNull(queueView);
    CompositeData[] compdatalist = queueView.browse();
    if (compdatalist.length == 0) {
        fail("There is no message in the queue:");
    }
    CompositeData cdata = compdatalist[0];
    assertComplexData(0, cdata, "Text", "Test Text Message: " + 0);
    assertMessageAreCorrect(1);
}
Also used : CompositeData(javax.management.openmbean.CompositeData) QueueViewMBean(org.apache.activemq.broker.jmx.QueueViewMBean) Test(org.junit.Test)

Example 9 with QueueViewMBean

use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.

the class BrokerNetworkWithStuckMessagesTest method browseQueueWithJmx.

private Object[] browseQueueWithJmx(BrokerService broker) throws Exception {
    Hashtable<String, String> params = new Hashtable<>();
    params.put("brokerName", broker.getBrokerName());
    params.put("type", "Broker");
    params.put("destinationType", "Queue");
    params.put("destinationName", queueName);
    ObjectName queueObjectName = ObjectName.getInstance(amqDomain, params);
    ManagementContext mgmtCtx = broker.getManagementContext();
    QueueViewMBean queueView = (QueueViewMBean) mgmtCtx.newProxyInstance(queueObjectName, QueueViewMBean.class, true);
    Object[] messages = queueView.browse();
    LOG.info("+Browsed with JMX: " + messages.length);
    return messages;
}
Also used : Hashtable(java.util.Hashtable) QueueViewMBean(org.apache.activemq.broker.jmx.QueueViewMBean) ManagementContext(org.apache.activemq.broker.jmx.ManagementContext) ObjectName(javax.management.ObjectName)

Example 10 with QueueViewMBean

use of org.apache.activemq.broker.jmx.QueueViewMBean in project activemq-artemis by apache.

the class OpenTypeSupportTest method bytesMessagePreview.

@Test
public void bytesMessagePreview() throws Exception {
    QueueViewMBean queue = getProxyToQueueViewMBean();
    assertEquals(extractText(queue.browse()[0]), extractText(queue.browse()[0]));
}
Also used : QueueViewMBean(org.apache.activemq.broker.jmx.QueueViewMBean) Test(org.junit.Test)

Aggregations

QueueViewMBean (org.apache.activemq.broker.jmx.QueueViewMBean)19 ObjectName (javax.management.ObjectName)12 CompositeData (javax.management.openmbean.CompositeData)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 MBeanServerConnection (javax.management.MBeanServerConnection)2 JMXConnector (javax.management.remote.JMXConnector)2 JMXServiceURL (javax.management.remote.JMXServiceURL)2 ManagementContext (org.apache.activemq.broker.jmx.ManagementContext)2 QueueMBean (org.motechproject.admin.domain.QueueMBean)2 MotechException (org.motechproject.commons.api.MotechException)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 LinkedList (java.util.LinkedList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Connection (javax.jms.Connection)1