Package org.apache.activemq.broker.region

Examples of org.apache.activemq.broker.region.Destination


            }
        }

        connection.close();
        Thread.sleep(1000);
        Destination dest = backEnd.getRegionBroker().getDestinationMap().get(topic);
        assertNotNull(dest);
        assertTrue(dest.getConsumers().isEmpty());
    }
View Full Code Here


    public void testUnsubscribe() throws Exception {
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        session.createDurableSubscriber(topic, "SubsId");
        session.close();

        Destination d = broker.getDestination(topic);
        assertEquals("Subscription is missing.", 1, d.getConsumers().size());


        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(topic);
        for (int i = 0; i < 1000; i++) {
            producer.send(session.createTextMessage("text"));
        }

        Thread.sleep(1000);

        session.unsubscribe("SubsId");
        session.close();

        assertEquals("Subscription exists.", 0, d.getConsumers().size());
    }
View Full Code Here

        connection.close();
        connection = null;
        Thread.sleep(1000);

        Destination d = broker.getDestination(topic);
        assertEquals("Subscription is missing.", 1, d.getConsumers().size());

        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName[] subNames = broker.getAdminView().getInactiveDurableTopicSubscribers();
        mbs.invoke(subNames[0], "destroy", new Object[0], new String[0]);

        assertEquals("Subscription exists.", 0, d.getConsumers().size());
    }
View Full Code Here

    public void testActivateWithExistingTopic() throws Exception {
        // create durable subscription
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        session.createDurableSubscriber(topic, "SubsId");

        Destination d = broker.getDestination(topic);
        assertTrue("More than one consumer found: " + d.getConsumers().size(), d.getConsumers().size() == 1);

        // restart the broker
        restartBroker();

        d = broker.getDestination(topic);
        assertTrue("More than one consumer found: " + d.getConsumers().size(), d.getConsumers().size() == 1);

        // activate
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        session.createDurableSubscriber(topic, "SubsId");

        assertTrue("More than one consumer found: " + d.getConsumers().size(), d.getConsumers().size() == 1);

        // re-activate
        connection.close();
        connection = createConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        session.createDurableSubscriber(topic, "SubsId");

        assertTrue("More than one consumer found: " + d.getConsumers().size(), d.getConsumers().size() == 1);
    }
View Full Code Here

    private void assertCount(int all, int active) throws Exception {
        int inactive = all - active;

        // broker check
        Destination destination = broker.getDestination(topic);
        List<Subscription> subs = destination.getConsumers();
        int cActive = 0, cInactive = 0;
        for (Subscription sub: subs) {
            if (sub instanceof DurableTopicSubscription) {
                DurableTopicSubscription durable = (DurableTopicSubscription) sub;
                if (durable.isActive())
View Full Code Here

        }
        return securityContext;
    }

    protected boolean checkDestinationAdmin(SecurityContext securityContext, ActiveMQDestination destination) {
        Destination existing = this.getDestinationMap().get(destination);
        if (existing != null) {
            return true;
        }

        if (!securityContext.isBrokerContext()) {
View Full Code Here

            subscriber.close();
            subscriberSession.close();
        }
        connection.close();
        Thread.sleep(1000);
        Destination dest = backEnd.getRegionBroker().getDestinationMap().get(topic);
        assertNotNull(dest);
        assertTrue(dest.getConsumers().isEmpty());
    }
View Full Code Here

            subscriber.close();
        }
        subscriberSession.close();
        connection.close();
        Thread.sleep(1000);
        Destination dest = backEnd.getRegionBroker().getDestinationMap().get(topic);
        assertNotNull(dest);
        assertTrue(dest.getConsumers().isEmpty());

    }
View Full Code Here

        subscriber.setMessageListener(listener);
        subscriber.close();
        subscriberSession.close();
        connection.close();
        Thread.sleep(1000);
        Destination dest = backEnd.getRegionBroker().getDestinationMap().get(topic);
        assertNotNull(dest);
        assertTrue(dest.getConsumers().isEmpty());
    }
View Full Code Here

            TopicSubscriber subscriber = subscriberSession.createSubscriber(topic);
        }

        connection.close();
        Thread.sleep(1000);
        Destination dest = backEnd.getRegionBroker().getDestinationMap().get(topic);
        assertNotNull(dest);
        assertTrue(dest.getConsumers().isEmpty());
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.broker.region.Destination

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.