Package org.apache.activemq.broker.jmx

Examples of org.apache.activemq.broker.jmx.DestinationViewMBean


        ActiveMQDestination amqDest = (ActiveMQDestination)destination;
        ObjectName destinationViewMBean = new ObjectName("org.apache.activemq:destinationType=" +
                (amqDest.isTopic() ? "Topic" : "Queue") +",destinationName="
                + amqDest.getPhysicalName() + ",type=Broker,brokerName=localhost");

        final DestinationViewMBean destView = (DestinationViewMBean) broker.getManagementContext().newProxyInstance(destinationViewMBean, DestinationViewMBean.class, true);

        assertTrue("Consumer gone from broker view", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                LOG.info("DestView {} comsumerCount {}", destView, destView.getConsumerCount());
                return 0 == destView.getConsumerCount();
            }
        }));

        socketProxy.goOn();
View Full Code Here


    protected DestinationViewMBean getDestinationByName(Collection<? extends DestinationViewMBean> collection,
            String name) {
        Iterator<? extends DestinationViewMBean> iter = collection.iterator();
        while (iter.hasNext()) {
            DestinationViewMBean destinationViewMBean = iter.next();
            if (name.equals(destinationViewMBean.getName())) {
                return destinationViewMBean;
            }
        }
        return null;
    }
View Full Code Here

            if (brokerInfo == null || !isInLocalMBeanServer(brokerInfo)) {
                return stat;
            }
            MBeanServer server = getMBeanServer();
            ObjectName objName = createDestinationObjectName(brokerInfo.getBrokerName(), destinationInfo.getType().name(), destinationInfo.getPhysicalName());
            DestinationViewMBean proxy;
            if (destinationInfo.getType().equals(DestinationType.Queue)) {
                if (!server.isRegistered(objName)) {
                    // mbean is not yet registered.Adding the destination to activemq broker.
                    ObjectName brokerObj = createBrokerObjectName(brokerInfo.getBrokerName());
                    Set set = server.queryMBeans(brokerObj, null);
                    Iterator it = set.iterator();
                    if (it.hasNext()) {
                        ObjectInstance instance = (ObjectInstance) it.next();
                        brokerObj = instance.getObjectName();
                    }
                    BrokerViewMBean brokerMBean = (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(server, brokerObj, BrokerViewMBean.class, true);
                    brokerMBean.addQueue(destinationInfo.getPhysicalName());
                }
                proxy = (DestinationViewMBean) MBeanServerInvocationHandler.newProxyInstance(server, objName, QueueViewMBean.class, true);
            } else {
                if (!server.isRegistered(objName)) {
                    // mbean is not yet registered.Adding the destination to activemq broker.
                    ObjectName brokerObj = createBrokerObjectName(brokerInfo.getBrokerName());
                    Set set = server.queryMBeans(brokerObj, null);
                    Iterator it = set.iterator();
                    if (it.hasNext()) {
                        ObjectInstance instance = (ObjectInstance) it.next();
                        brokerObj = instance.getObjectName();
                    }
                    BrokerViewMBean brokerMBean = (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(server, brokerObj, BrokerViewMBean.class, true);
                    brokerMBean.addTopic(destinationInfo.getPhysicalName());
                }
                proxy = (DestinationViewMBean) MBeanServerInvocationHandler.newProxyInstance(server, objName, TopicViewMBean.class, true);
            }
            stat.setConsumerCount(proxy.getConsumerCount());
            stat.setEnqueueCount(proxy.getEnqueueCount());
            stat.setDequeueCount(proxy.getDequeueCount());
            stat.setQueueSize(proxy.getQueueSize());
        } catch (Exception ex) {
            logger.warn("Failed to get ActiveMQ stats", ex);
        }
        return stat;
    }
View Full Code Here

        producer.setDeliveryMode(DeliveryMode.PERSISTENT);
        connection.start();
       
        producer.send(session.createTextMessage("test123"));
       
        DestinationViewMBean dv = createView();
        assertTrue(dv.getQueueSize() > 0);
       
        connection.close();
       
        broker.stop();
        broker.waitUntilStopped();
       
        createBroker(false);
        factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
        connection = factory.createConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        producer = session.createProducer(session.createQueue("test"));
        producer.setDeliveryMode(DeliveryMode.PERSISTENT);
        connection.start();
        producer.send(session.createTextMessage("test123"));
        connection.close();
       
        dv = createView();
        assertTrue(dv.getQueueSize() > 0);
       
        broker.stop();
        broker.waitUntilStopped();
       
  }
View Full Code Here

                producingThread.join(1000);
                return !producingThread.isAlive();
            }
    }));
   
        final DestinationViewMBean view = createView(destination);
        Wait.waitFor(new Wait.Condition() {
            public boolean isSatisified() throws Exception {
                LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
                        + ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
                        + ", size= " + view.getQueueSize());
                return sendCount == view.getExpiredCount();
            }
        });
        LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
                + ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
                + ", size= " + view.getQueueSize());
       
        assertEquals("All sent have expired", sendCount, view.getExpiredCount());
        assertEquals("memory usage goes to duck egg", 0, view.getMemoryPercentUsage());
  }
View Full Code Here

                producingThread.join(1000);
                return !producingThread.isAlive();
            }     
        }));
            
        final DestinationViewMBean view = createView(destination);
           
        assertTrue("all dispatched up to default prefetch ", Wait.waitFor(new Wait.Condition() {
            public boolean isSatisified() throws Exception {
                return queuePrefetch == view.getDispatchCount();
            }
        }));
        assertTrue("All sent have expired ", Wait.waitFor(new Wait.Condition() {
            public boolean isSatisified() throws Exception {
                return sendCount == view.getExpiredCount();
            }
        }));    
       
        LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
                + ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
                + ", size= " + view.getQueueSize());
       
        // let the ack happen
        waitCondition.countDown();
       
        Wait.waitFor(new Wait.Condition() {
            public boolean isSatisified() throws Exception {
                // consumer ackLater(delivery ack for expired messages) is based on half the prefetch value
                // which will leave half of the prefetch pending till consumer close
                return (queuePrefetch/2) -1 == view.getInFlightCount();
            }
        });
        LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
                + ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
                + ", size= " + view.getQueueSize());
       
       
        assertEquals("inflight reduces to half prefetch minus single delivered message", (queuePrefetch/2) -1, view.getInFlightCount());
        assertEquals("size gets back to 0 ", 0, view.getQueueSize());
        assertEquals("dequeues match sent/expired ", sendCount, view.getDequeueCount());
       
        consumer.close();
       
        Wait.waitFor(new Wait.Condition() {
            public boolean isSatisified() throws Exception {
                return 0 == view.getInFlightCount();
            }
        });
        assertEquals("inflight goes to zeor on close", 0, view.getInFlightCount());
     
        LOG.info("done: " + getName());
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.broker.jmx.DestinationViewMBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.