Examples of BrokerView


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

            getBroker().start();
            if (isUseJmx()) {
                getManagementContext().start();
                ManagedRegionBroker managedBroker = (ManagedRegionBroker) regionBroker;
                managedBroker.setContextBroker(broker);
                adminView = new BrokerView(this, managedBroker);
                ObjectName objectName = getBrokerObjectName();
                AnnotatedMBean.registerMBean(getManagementContext(), adminView, objectName);
            }
            BrokerRegistry.getInstance().bind(getBrokerName(), this);
            // see if there is a MasterBroker service and if so, configure
View Full Code Here

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

    public void simpleDurableTopicTest() throws Exception {
        String TOPIC_NAME = "topic://AMQ4696Test" + System.currentTimeMillis();
        String durableClientId = "AMQPDurableTopicTestClient";
        String durableSubscriberName = "durableSubscriberName";

        BrokerView adminView = this.brokerService.getAdminView();
        int durableSubscribersAtStart = adminView.getDurableTopicSubscribers().length;
        int inactiveSubscribersAtStart = adminView.getInactiveDurableTopicSubscribers().length;
        LOG.debug(">>>> At Start, durable Subscribers {} inactiveDurableSubscribers {}", durableSubscribersAtStart, inactiveSubscribersAtStart);

        TopicConnectionFactory factory = new ConnectionFactoryImpl("localhost", port, "admin", "password");
        Topic topic = new TopicImpl("topic://" + TOPIC_NAME);
        TopicConnection subscriberConnection = factory.createTopicConnection();
        subscriberConnection.setClientID(durableClientId);
        TopicSession subscriberSession = subscriberConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        TopicSubscriber messageConsumer = subscriberSession.createDurableSubscriber(topic, durableSubscriberName);

        assertNotNull(messageConsumer);

        int durableSubscribers = adminView.getDurableTopicSubscribers().length;
        int inactiveSubscribers = adminView.getInactiveDurableTopicSubscribers().length;
        LOG.debug(">>>> durable Subscribers after creation {} inactiveDurableSubscribers {}", durableSubscribers, inactiveSubscribers);
        assertEquals("Wrong number of durable subscribers after first subscription", 1, (durableSubscribers - durableSubscribersAtStart));
        assertEquals("Wrong number of inactive durable subscribers after first subscription", 0, (inactiveSubscribers - inactiveSubscribersAtStart));

        subscriberConnection.close();
        subscriberConnection = null;

        durableSubscribers = adminView.getDurableTopicSubscribers().length;
        inactiveSubscribers = adminView.getInactiveDurableTopicSubscribers().length;
        LOG.debug(">>>> durable Subscribers after close {} inactiveDurableSubscribers {}", durableSubscribers, inactiveSubscribers);
        assertEquals("Wrong number of durable subscribers after close", 0, (durableSubscribersAtStart));
        assertEquals("Wrong number of inactive durable subscribers after close", 1, (inactiveSubscribers - inactiveSubscribersAtStart));
    }
View Full Code Here

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

    }

    protected void startManagementContext() throws Exception {
        getManagementContext().setBrokerName(brokerName);
        getManagementContext().start();
        adminView = new BrokerView(this, null);
        ObjectName objectName = getBrokerObjectName();
        AnnotatedMBean.registerMBean(getManagementContext(), adminView, objectName);
    }
View Full Code Here

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

  }
  public BrokerViewMBean getBrokerAdmin() throws Exception {
    return brokerService.getAdminView();
  }
  public ManagedRegionBroker getManagedBroker() throws Exception {
    BrokerView adminView = brokerService.getAdminView();
    if (adminView == null) {
      return null;
    }
    return adminView.getBroker();
  }
View Full Code Here

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

        for (int i = 0; i < 5000; i++) {
            sendMessage(false);
        }

        final BrokerView brokerView = broker.getAdminView();

        // wait for reclaim
        assertTrue("in range with consumer",
                Wait.waitFor(new Wait.Condition() {
                    public boolean isSatisified() throws Exception {
                        // usage percent updated only on send check for isFull so once
                        // sends complete it is no longer updated till next send via a call to isFull
                        // this is optimal as it is only used to block producers
                        broker.getSystemUsage().getStoreUsage().isFull();
                        LOG.info("store percent usage: "+brokerView.getStorePercentUsage());
                        return broker.getAdminView().getStorePercentUsage() < minPercentUsageForStore;
                    }
                }));


        closeConsumer();

        assertTrue("in range with closed consumer",
                Wait.waitFor(new Wait.Condition() {
                    public boolean isSatisified() throws Exception {
                        broker.getSystemUsage().getStoreUsage().isFull();
                        LOG.info("store precent usage: "+brokerView.getStorePercentUsage());
                        return broker.getAdminView().getStorePercentUsage() < minPercentUsageForStore;
                    }
                }));

        for (int i = 0; i < 5000; i++) {
            sendMessage(false);
        }

        // What if i drop the subscription?
        broker.getAdminView().destroyDurableSubscriber("cliID", "subName");

        assertTrue("in range after send with consumer",
                Wait.waitFor(new Wait.Condition() {
                    public boolean isSatisified() throws Exception {
                        broker.getSystemUsage().getStoreUsage().isFull();
                        LOG.info("store precent usage: "+brokerView.getStorePercentUsage());                       
                        return broker.getAdminView().getStorePercentUsage() < minPercentUsageForStore;
                    }
                }));

    }
View Full Code Here

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

    private boolean verifyDurableConsumerCount(final long expectedCount, final BrokerService broker) throws Exception {
        return Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                boolean result = false;
                BrokerView view = broker.getAdminView();

                if (view != null) {
                    ObjectName[] subs = broker.getAdminView().getInactiveDurableTopicSubscribers();
                    if (subs != null) {
                        LOG.info("inactive durable subs on " + broker + " : " + subs);
View Full Code Here

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

        for (int i = 0; i < numMessages; i++) {
            sendMessage(false);
        }

        final BrokerView brokerView = broker.getAdminView();

        broker.getSystemUsage().getStoreUsage().isFull();
        LOG.info("store percent usage: " + brokerView.getStorePercentUsage());
        assertTrue("redelivery consumer got all it needs, remaining: "
                + redeliveryConsumerLatch.getCount(), redeliveryConsumerLatch.await(60, TimeUnit.SECONDS));
        assertTrue("dql  consumer got all it needs", dlqConsumerLatch.await(60, TimeUnit.SECONDS));
        closeConsumer();
View Full Code Here

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

        assertEquals("received expected amount", 500, receiveExactMessages("BrokerB", 500));
        validateQueueStats();
    }
   
    private void validateQueueStats() throws Exception {
       final BrokerView brokerView = brokers.get("BrokerA").broker.getAdminView();
       assertEquals("enequeue is correct", 1000, brokerView.getTotalEnqueueCount());
      
       assertTrue("dequeue is correct", Wait.waitFor(new Wait.Condition() {
           public boolean isSatisified() throws Exception {
               LOG.info("dequeue count (want 1000), is : " + brokerView.getTotalDequeueCount());
               return 1000 == brokerView.getTotalDequeueCount();
           }
       }));
    }
View Full Code Here

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

        Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(destination);
        producer.setDeliveryMode(deliveryMode);

        final BrokerView brokerView = broker.getAdminView();

        assertEquals(1, brokerView.getDurableTopicSubscribers().length);

        LOG.info("Current Durable Topic Subscriptions: " + brokerView.getDurableTopicSubscribers().length);

        try {
            brokerView.destroyDurableSubscriber("subscriber1", "myTopic");
            fail("Expected Exception for Durable consumer is in use");
        } catch(Exception e) {
            LOG.info("Recieved expected exception: " + e.getMessage());
        }

        LOG.info("Current Durable Topic Subscriptions: " + brokerView.getDurableTopicSubscribers().length);

        assertEquals(1, brokerView.getDurableTopicSubscribers().length);

        activeConsumer.close();
        consumerConnection.stop();

        assertTrue("The subscription should be in the inactive state.", Wait.waitFor(new Wait.Condition() {

            @Override
            public boolean isSatisified() throws Exception {
                return brokerView.getInactiveDurableTopicSubscribers().length == 1;
            }
        }));

        try {
            brokerView.destroyDurableSubscriber("subscriber1", "myTopic");
        } finally {
            producer.close();
            producerConnection.close();
        }
    }
View Full Code Here

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

        for (int i = 0; i < 5000; i++) {
            sendMessage(false);
        }

        final BrokerView brokerView = broker.getAdminView();

        broker.getSystemUsage().getStoreUsage().isFull();
        LOG.info("store percent usage: "+brokerView.getStorePercentUsage());
        assertTrue("some store in use", broker.getAdminView().getStorePercentUsage() > minPercentUsageForStore);

        assertTrue("redelivery consumer got all it needs", redeliveryConsumerLatch.await(60, TimeUnit.SECONDS));
        closeConsumer();

        // consume from DLQ
        final CountDownLatch received = new CountDownLatch(5000 -1);
        consumerConnection = (ActiveMQConnection) createConnection();
        Session dlqSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageConsumer dlqConsumer = dlqSession.createConsumer(new ActiveMQQueue("ActiveMQ.DLQ"));
        dlqConsumer.setMessageListener(new MessageListener() {
            @Override
            public void onMessage(Message message) {
                if (received.getCount() % 500 == 0) {
                    LOG.info("remaining on DLQ: " + received.getCount());
                }
                received.countDown();
            }
        });
        consumerConnection.start();

        assertTrue("Not all messages reached the DLQ", received.await(60, TimeUnit.SECONDS));

        assertTrue("Store usage exceeds expected usage",
                Wait.waitFor(new Wait.Condition() {
                    @Override
                    public boolean isSatisified() throws Exception {
                        broker.getSystemUsage().getStoreUsage().isFull();
                        LOG.info("store precent usage: "+brokerView.getStorePercentUsage());
                        return broker.getAdminView().getStorePercentUsage() < minPercentUsageForStore;
                    }
                }));

         closeConsumer();
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.