Examples of BrokerView


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();
        final TopicViewMBean topicView = getTopicView();

        assertTrue("Should have one consumer on topic: ", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                return topicView.getConsumerCount() == 1;
            }
        }));

        consumer.close();

        assertTrue("Durable consumer should now be inactive.", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                return brokerView.getInactiveDurableTopicSubscribers().length == 1;
            }
        }));

        try {
            brokerView.removeTopic(destination.getTopicName());
        } catch (Exception e1) {
            fail("Unable to remove destination:" + destination.getPhysicalName());
        }

        assertTrue("Should have no topics on the broker", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                return brokerView.getTopics().length == 0;
            }
        }));

        try {
            brokerView.destroyDurableSubscriber("subscriber1", "myTopic");
        } catch(Exception e) {
            fail("Exception not expected when attempting to delete Durable consumer.");
        }

        assertTrue("Should be no durable consumers active or inactive.", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                return brokerView.getInactiveDurableTopicSubscribers().length == 0 &&
                       brokerView.getDurableTopicSubscribers().length == 0;
            }
        }));

        consumer = consumerMQSession.createDurableSubscriber(destination, "myTopic");

        consumer.close();

        assertTrue("Should be one consumer on the Topic.", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                LOG.info("Number of inactive consumers: " + brokerView.getInactiveDurableTopicSubscribers().length);
                return brokerView.getInactiveDurableTopicSubscribers().length == 1;
            }
        }));

        final TopicViewMBean recreatedTopicView = getTopicView();
View Full Code Here

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

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createTopic("DurableTopic");

        MessageConsumer consumer = session.createDurableSubscriber((Topic) destination, "EnqueueSub");

        BrokerView view = brokerService.getAdminView();
        view.getDurableTopicSubscribers();

        ObjectName subName = view.getDurableTopicSubscribers()[0];

        DurableSubscriptionViewMBean sub = (DurableSubscriptionViewMBean)
            brokerService.getManagementContext().newProxyInstance(subName, DurableSubscriptionViewMBean.class, true);

        assertEquals(0, sub.getEnqueueCounter());
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 {
       BrokerView brokerView = brokers.get("BrokerA").broker.getAdminView();
       assertEquals("enequeue is correct", 1000, brokerView.getTotalEnqueueCount());
       assertEquals("dequeue is correct", 1000, brokerView.getTotalDequeueCount());
    }
View Full Code Here

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

        slaveStartSignal.countDown();
    }
   
    protected void startManagementContext() throws Exception {
        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

        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 {
               return 1000 == brokerView.getTotalDequeueCount();
           }
       }));
    }
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 precent 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

        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() {
            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() {
                    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

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

        slaveStartSignal.countDown();
    }
   
    protected void startManagementContext() throws Exception {
        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

    }

    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
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.