Package org.apache.activemq.broker.jmx

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


    private boolean destinationPresentInAdminView(BrokerService broker2, ActiveMQTopic amqTopic) throws Exception {
        boolean found = false;
        for (ObjectName name : broker.getAdminView().getTopics()) {

            DestinationViewMBean proxy = (DestinationViewMBean)
                broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true);

            if (proxy.getName().equals(amqTopic.getPhysicalName())) {
                found = true;
                break;
            }
        }
        return found;
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 {
                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());
  }
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 1000 == 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 {
                return 0 == view.getInFlightCount();
            }
        });
        LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
                + ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
                + ", size= " + view.getQueueSize());
        assertEquals("prefetch gets back to 0 ", 0, view.getInFlightCount());
        assertEquals("size gets back to 0 ", 0, view.getQueueSize());
        assertEquals("dequeues match sent/expired ", sendCount, view.getDequeueCount());
       
        consumer.close();
        LOG.info("done: " + getName());
    }
View Full Code Here

   
        consumerThread.join();
        producingThread.join();
        session.close();
       
        final DestinationViewMBean view = createView(destination);
       
        // wait for all to inflight to expire
        assertTrue("all inflight messages expired ", Wait.waitFor(new Wait.Condition() {
            public boolean isSatisified() throws Exception {
                return view.getInFlightCount() == 0;
            }          
        }));
        assertEquals("Wrong inFlightCount: ", 0, view.getInFlightCount());
       
        LOG.info("Stats: received: "  + received.get() + ", enqueues: " + view.getDequeueCount() + ", dequeues: " + view.getDequeueCount()
                + ", dispatched: " + view.getDispatchCount() + ", inflight: " + view.getInFlightCount() + ", expiries: " + view.getExpiredCount());
       
        // wait for all sent to get delivered and expire
        assertTrue("all sent messages expired ", Wait.waitFor(new Wait.Condition() {
            public boolean isSatisified() throws Exception {
                long oldEnqueues = view.getEnqueueCount();
                Thread.sleep(200);
                LOG.info("Stats: received: "  + received.get() + ", size= " + view.getQueueSize() + ", enqueues: " + view.getDequeueCount() + ", dequeues: " + view.getDequeueCount()
                        + ", dispatched: " + view.getDispatchCount() + ", inflight: " + view.getInFlightCount() + ", expiries: " + view.getExpiredCount());
                return oldEnqueues == view.getEnqueueCount();
            }          
        }, 60*1000));
       

        LOG.info("Stats: received: "  + received.get() + ", size= " + view.getQueueSize() + ", enqueues: " + view.getDequeueCount() + ", dequeues: " + view.getDequeueCount()
                + ", dispatched: " + view.getDispatchCount() + ", inflight: " + view.getInFlightCount() + ", expiries: " + view.getExpiredCount());
       
        assertTrue("got at least what did not expire", received.get() >= view.getDequeueCount() - view.getExpiredCount());
       
        assertTrue("all messages expired - queue size gone to zero " + view.getQueueSize(), Wait.waitFor(new Wait.Condition() {
            public boolean isSatisified() throws Exception {
                return view.getQueueSize() == 0;
            }
        }));
       
        final long expiredBeforeEnqueue = numMessagesToSend - view.getEnqueueCount();
        final long totalExpiredCount = view.getExpiredCount() + expiredBeforeEnqueue;
       
        final DestinationViewMBean dlqView = createView(dlqDestination);
        LOG.info("DLQ stats: size= " + dlqView.getQueueSize() + ", enqueues: " + dlqView.getDequeueCount() + ", dequeues: " + dlqView.getDequeueCount()
                + ", dispatched: " + dlqView.getDispatchCount() + ", inflight: " + dlqView.getInFlightCount() + ", expiries: " + dlqView.getExpiredCount());
       
        Wait.waitFor(new Wait.Condition() {
            public boolean isSatisified() throws Exception {
                return totalExpiredCount == dlqView.getQueueSize();
            }
        });
        assertEquals("dlq contains all expired", totalExpiredCount, dlqView.getQueueSize());
       
        // verify DQL
        MessageConsumer dlqConsumer = createDlqConsumer(connection);
        int count = 0;
        while (dlqConsumer.receive(4000) != null) {
View Full Code Here

        };

        producingThread.start();
        producingThread.join();

        DestinationViewMBean view = createView(destination);
        LOG.info("Stats: size: " + view.getQueueSize() + ", enqueues: "
                + view.getDequeueCount() + ", dequeues: "
                + view.getDequeueCount() + ", dispatched: "
                + view.getDispatchCount() + ", inflight: "
                + view.getInFlightCount() + ", expiries: "
                + view.getExpiredCount());

        LOG.info("stopping broker");
        broker.stop();
        broker.waitUntilStopped();

        Thread.sleep(5000);

        LOG.info("recovering broker");
        final boolean deleteAllMessages = false;
        broker = createBroker(deleteAllMessages, 5000);
       
        view = createView(destination);
        LOG.info("Stats: size: " + view.getQueueSize() + ", enqueues: "
                + view.getDequeueCount() + ", dequeues: "
                + view.getDequeueCount() + ", dispatched: "
                + view.getDispatchCount() + ", inflight: "
                + view.getInFlightCount() + ", expiries: "
                + view.getExpiredCount());

        long expiry = System.currentTimeMillis() + 30000;
        while (view.getQueueSize() > 0 && System.currentTimeMillis() < expiry) {
            Thread.sleep(500);
        }
        LOG.info("Stats: size: " + view.getQueueSize() + ", enqueues: "
                + view.getDequeueCount() + ", dequeues: "
                + view.getDequeueCount() + ", dispatched: "
                + view.getDispatchCount() + ", inflight: "
                + view.getInFlightCount() + ", expiries: "
                + view.getExpiredCount());
        assertEquals("Wrong QueueSize: ", 0, view.getQueueSize());
        assertEquals("all dequeues were expired", view.getDequeueCount(), view.getExpiredCount());
    }
View Full Code Here

        }

        waitForMinTopicRegionConsumerCount("BrokerB", 1);
        waitForMinTopicRegionConsumerCount("BrokerA", 1);

        final DestinationViewMBean brokerAView = createView("BrokerA", "ActiveMQ.Advisory.TempQueue", ActiveMQDestination.TOPIC_TYPE);
        assertTrue("exact amount of advisories created on A, one each for creation/deletion", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                LOG.info("BrokerA temp advisory enque count: " + brokerAView.getEnqueueCount());
                return iterations * 2 == brokerAView.getEnqueueCount();
            }
        }));

        final DestinationViewMBean brokerBView = createView("BrokerB", "ActiveMQ.Advisory.TempQueue", ActiveMQDestination.TOPIC_TYPE);
        assertTrue("exact amount of advisories created on B, one each for creation/deletion", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                LOG.info("BrokerB temp advisory enque count: " + brokerBView.getEnqueueCount());
                return iterations * 2 == brokerBView.getEnqueueCount();
            }
        }));
    }
View Full Code Here

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

        DestinationViewMBean queue = (DestinationViewMBean) broker.getManagementContext().newProxyInstance(destinationViewMBean, DestinationViewMBean.class, true);
        ObjectName slowConsumerPolicyMBeanName = queue.getSlowConsumerStrategy();

        assertNotNull(slowConsumerPolicyMBeanName);

        AbortSlowConsumerStrategyViewMBean abortPolicy = (AbortSlowConsumerStrategyViewMBean)
                broker.getManagementContext().newProxyInstance(slowConsumerPolicyMBeanName, AbortSlowConsumerStrategyViewMBean.class, true);
View Full Code Here

        }

        // we should delay a bit so broker can run its expiration processes...
        assertFalse(expireMatcher.matches(2, TimeUnit.SECONDS));

        DestinationViewMBean queue = getQueueMBean(TEST_INOUT_DESTINATION_NAME);
        assertEquals("There were unexpected messages left in the queue: " + TEST_INOUT_DESTINATION_NAME,
                0, queue.getQueueSize());
    }
View Full Code Here

        template.sendBody(endpoint, "test message");

        // we should delay a bit so broker can run its expiration processes...
        assertFalse(expireMatcher.matches(2, TimeUnit.SECONDS));

        DestinationViewMBean queue = getQueueMBean(TEST_INONLY_DESTINATION_NAME);
        assertEquals("There were unexpected messages left in the queue: " + TEST_INONLY_DESTINATION_NAME,
                0, queue.getQueueSize());
    }
View Full Code Here

        assertNotNull(response);
        dar = (DataArrayResponse)response;
        assertEquals(4, dar.getData().length);

        // validate destination depth via jmx
        DestinationViewMBean destinationView = getProxyToDestination(destinationList(destination)[0]);
        assertEquals("enqueue count does not see prepared", 0, destinationView.getQueueSize());

        TransactionId first = (TransactionId)dar.getData()[0];
        int commitCount = 0;
        // via jmx, force outcome
        for (int i = 0; i < 4; i++) {
            RecoveredXATransactionViewMBean mbean =  getProxyToPreparedTransactionViewMBean((TransactionId)dar.getData()[i]);
            if (i%2==0) {
                mbean.heuristicCommit();
                commitCount++;
            } else {
                mbean.heuristicRollback();
            }
        }

        // verify all completed
        response = connection.request(new TransactionInfo(connectionInfo.getConnectionId(), null, TransactionInfo.RECOVER));
        assertNotNull(response);
        dar = (DataArrayResponse)response;
        assertEquals(0, dar.getData().length);

        // verify messages available
        assertEquals("enqueue count reflects outcome", commitCount, destinationView.getQueueSize());

        // verify mbeans gone
        try {
            RecoveredXATransactionViewMBean gone = getProxyToPreparedTransactionViewMBean(first);
            gone.heuristicRollback();
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.