Examples of DestinationViewMBean


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

        m = receiveMessage(connection);
        assertNull(m);
        assertNoMessagesLeft(connection);

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

        connection.request(createCommitTransaction2Phase(connectionInfo, txid));

        // validate recovery complete
        dataArrayResponse = (DataArrayResponse)connection.request(recoverInfo);
        assertEquals("there are no prepared tx", 0, dataArrayResponse.getData().length);

        assertEquals("enqueue count does not see commited acks", 0, destinationView.getQueueSize());
        assertEquals("enqueue count does not see commited acks", 4, destinationView.getDequeueCount());

    }
View Full Code Here

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

                producingThread.join(1000);
                return !producingThread.isAlive();
            }
        }, Wait.MAX_WAIT_MILLIS * 10));

        final DestinationViewMBean view = createView(destination);

        assertTrue("Not all dispatched up to default prefetch ", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                return queuePrefetch == view.getDispatchCount();
            }
        }));
        assertTrue("All have not sent have expired ", Wait.waitFor(new Wait.Condition() {
            @Override
            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() {
            @Override
            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("inflight didn't reduce to duck",
                     0, view.getInFlightCount());
        assertEquals("size doesn't get back to 0 ", 0, view.getQueueSize());
        assertEquals("dequeues don't match sent/expired ", sendCount, view.getDequeueCount());

        // produce some more
        producer.setTimeToLive(0);
        long tStamp = System.currentTimeMillis();
        for (int i=0; i<sendCount; i++) {
            producer.send(session.createTextMessage("test-" + i));
            if (i%100 == 0) {
                LOG.info("sent: " + i + " @ " + ((System.currentTimeMillis() - tStamp) / 100+ "m/ms");
                tStamp = System.currentTimeMillis() ;
            }
        }

        Wait.waitFor(new Wait.Condition() {
             @Override
            public boolean isSatisified() throws Exception {
                 return received.get() >= sendCount;
             }
         });

        consumer.close();

        Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                return 0 == view.getInFlightCount();
            }
        });
        assertEquals("inflight did not go to zero on close", 0, view.getInFlightCount());

        LOG.info("done: " + getName());
    }
View Full Code Here

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

        for (int i=0; i < sendCount; i++) {
            producer.send(session.createTextMessage("test"));
        }

        DestinationViewMBean view = createView((ActiveMQTopic)destination);

        LOG.info("messages sent");
        LOG.info("expired=" + view.getExpiredCount() + " " +  view.getEnqueueCount());
        assertEquals(0, view.getExpiredCount());
        assertEquals(10, view.getEnqueueCount());

        Thread.sleep(5000);

        LOG.info("expired=" + view.getExpiredCount() + " " +  view.getEnqueueCount());
        assertEquals(10, view.getExpiredCount());
        assertEquals(0, view.getEnqueueCount());

        final AtomicLong received = new AtomicLong();
        sub = session.createDurableSubscriber(destination, "mySub");
        sub.setMessageListener(new MessageListener() {
            @Override
            public void onMessage(Message message) {
                received.incrementAndGet();
            }
        });

        LOG.info("Waiting for messages to arrive");

        Wait.waitFor(new Wait.Condition() {
             @Override
            public boolean isSatisified() throws Exception {
                 return received.get() >= sendCount;
             }
         }, 1000);

        LOG.info("received=" + received.get());
        LOG.info("expired=" + view.getExpiredCount() + " " +  view.getEnqueueCount());

        assertEquals(0, received.get());
        assertEquals(10, view.getExpiredCount());
        assertEquals(0, view.getEnqueueCount());
    }
View Full Code Here

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

            }
        }));

        TimeUnit.SECONDS.sleep(5);

        final DestinationViewMBean view = createView(destination);
        Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                try {
                LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
                        + ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
                        + ", size= " + view.getQueueSize());
                return view.getDequeueCount() != 0
                        && view.getDequeueCount() == view.getExpiredCount()
                        && view.getDequeueCount() == view.getEnqueueCount()
                        && view.getQueueSize() == 0;
                } catch (Exception ignored) {
                    LOG.info(ignored.toString());
                }
                return false;
            }
        }, Wait.MAX_WAIT_MILLIS * 10);
        LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
                + ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
                + ", size= " + view.getQueueSize());

        assertEquals("memory usage doesn't go to duck egg", 0, view.getMemoryPercentUsage());
        assertEquals("0 queue", 0, view.getQueueSize());
    }
View Full Code Here

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

                producingThread.join(TimeUnit.SECONDS.toMillis(3000));
                return !producingThread.isAlive();
            }
        }));

        final DestinationViewMBean view = createView(destination);
        Wait.waitFor(new Wait.Condition() {
            @Override
            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();
            }
        }, Wait.MAX_WAIT_MILLIS * 10);
        LOG.info("enqueue=" + view.getEnqueueCount() + ", dequeue=" + view.getDequeueCount()
                + ", inflight=" + view.getInFlightCount() + ", expired= " + view.getExpiredCount()
                + ", size= " + view.getQueueSize());

        assertEquals("Not all sent messages have expired", sendCount, view.getExpiredCount());
        assertEquals("memory usage doesn't go to duck egg", 0, view.getMemoryPercentUsage());
    }
View Full Code Here

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

                producingThread.join(1000);
                return !producingThread.isAlive();
            }
        }, Wait.MAX_WAIT_MILLIS * 10));

        final DestinationViewMBean view = createView(destination);

        assertTrue("all dispatched up to default prefetch ", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                return queuePrefetch == view.getDispatchCount();
            }
        }));
        assertTrue("Not all sent have expired ", Wait.waitFor(new Wait.Condition() {
            @Override
            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() {
            @Override
            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("inflight reduced to duck",
                     0, view.getInFlightCount());
        assertEquals("size didn't get back to 0 ", 0, view.getQueueSize());
        assertEquals("dequeues didn't match sent/expired ", sendCount, view.getDequeueCount());

        consumer.close();

        Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                return 0 == view.getInFlightCount();
            }
        });
        assertEquals("inflight goes to zero on close", 0, view.getInFlightCount());

        LOG.info("done: " + getName());
    }
View Full Code Here

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

            // force an ack when there are expired messages
            amqConsumer.acknowledge();        
        }
        assertEquals("consumer has expiredMessages", count, amqConsumer.getConsumerStats().getExpiredMessageCount().getCount());
   
        DestinationViewMBean view = createView(destination);
       
        assertEquals("Wrong inFlightCount: " + view.getInFlightCount(), 0, view.getInFlightCount());
        assertEquals("Wrong dispatch count: " + view.getDispatchCount(), 8, view.getDispatchCount());
        assertEquals("Wrong dequeue count: " + view.getDequeueCount(), 8, view.getDequeueCount());
    }
View Full Code Here

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

                        destinations = broker.getAdminView().getTopics();
                    }

                    // We should have 1 consumer for the queue on the local broker
                    for (ObjectName name : destinations) {
                        DestinationViewMBean view = (DestinationViewMBean)
                            broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true);

                        if (view.getName().equals(destination.getPhysicalName())) {
                            LOG.info("Consumers for " + destination.getPhysicalName() + " on " + broker + " : " + view.getConsumerCount());
                            if (expectedCount == view.getConsumerCount()) {
                                result = true;
                            }
                        }
                    }
View Full Code Here

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

        }

        // Let the messages expire
        Thread.sleep(2000);

        DestinationViewMBean view = createView(destination);

        assertEquals("Incorrect inflight count: " + view.getInFlightCount(), 0, view.getInFlightCount());
        assertEquals("Incorrect queue size count", 0, view.getQueueSize());
        assertEquals("Incorrect expired size count", view.getEnqueueCount(), view.getExpiredCount());

        // Send more messages with an expiration
        for (int i = 0; i < count; i++) {
            TextMessage message = producerSession.createTextMessage("" + i);
            producer.send(message);
        }

        // Let the messages expire
        Thread.sleep(2000);

        // Simply browse the queue
        Session browserSession = createSession();
        QueueBrowser browser = browserSession.createBrowser((Queue) destination);
        assertFalse("no message in the browser", browser.getEnumeration().hasMoreElements());

        // The messages expire and should be reaped because of the presence of
        // the queue browser
        assertEquals("Wrong inFlightCount: " + view.getInFlightCount(), 0, view.getInFlightCount());
    }
View Full Code Here

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

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