Examples of DestinationStatistics


Examples of org.apache.geronimo.console.jmsmanager.DestinationStatistics

        }
    }

    @Override
    public DestinationStatistics getDestinationStatistics(PortletRequest portletRequest, JMSDestinationInfo destinationInfo) throws JMSException {
        DestinationStatistics stat = new DestinationStatistics();
        try {
            BrokerInfo brokerInfo = getBrokerInfo(portletRequest, destinationInfo);
            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
TOP
Copyright © 2018 www.massapi.com. 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.