Search in sources :

Example 1 with Destination

use of org.apache.activemq.broker.region.Destination in project activemq-artemis by apache.

the class TempDestLoadTest method testLoadTempAdvisoryQueues.

public void testLoadTempAdvisoryQueues() throws Exception {
    for (int i = 0; i < MESSAGE_COUNT; i++) {
        TemporaryQueue tempQueue = session.createTemporaryQueue();
        MessageConsumer consumer = session.createConsumer(tempQueue);
        MessageProducer producer = session.createProducer(tempQueue);
        consumer.close();
        producer.close();
        tempQueue.delete();
    }
    AdvisoryBroker ab = (AdvisoryBroker) broker.getBroker().getAdaptor(AdvisoryBroker.class);
    assertTrue(ab.getAdvisoryDestinations().size() == 0);
    assertTrue(ab.getAdvisoryConsumers().size() == 0);
    assertTrue(ab.getAdvisoryProducers().size() == 0);
    RegionBroker rb = (RegionBroker) broker.getBroker().getAdaptor(RegionBroker.class);
    for (Destination dest : rb.getDestinationMap().values()) {
        LOG.debug("Destination: {}", dest);
    }
    // there should be at least 2 destinations - advisories -
    // 1 for the connection + 1 generic ones
    assertTrue("Should be at least 2 destinations", rb.getDestinationMap().size() > 2);
}
Also used : Destination(org.apache.activemq.broker.region.Destination) MessageConsumer(javax.jms.MessageConsumer) RegionBroker(org.apache.activemq.broker.region.RegionBroker) TemporaryQueue(javax.jms.TemporaryQueue) MessageProducer(javax.jms.MessageProducer)

Example 2 with Destination

use of org.apache.activemq.broker.region.Destination in project activemq-artemis by apache.

the class TempDestLoadTest method testLoadTempAdvisoryTopics.

public void testLoadTempAdvisoryTopics() throws Exception {
    for (int i = 0; i < MESSAGE_COUNT; i++) {
        TemporaryTopic tempTopic = session.createTemporaryTopic();
        MessageConsumer consumer = session.createConsumer(tempTopic);
        MessageProducer producer = session.createProducer(tempTopic);
        consumer.close();
        producer.close();
        tempTopic.delete();
    }
    AdvisoryBroker ab = (AdvisoryBroker) broker.getBroker().getAdaptor(AdvisoryBroker.class);
    assertTrue(ab.getAdvisoryDestinations().size() == 0);
    assertTrue(ab.getAdvisoryConsumers().size() == 0);
    assertTrue(ab.getAdvisoryProducers().size() == 0);
    RegionBroker rb = (RegionBroker) broker.getBroker().getAdaptor(RegionBroker.class);
    for (Destination dest : rb.getDestinationMap().values()) {
        LOG.debug("Destination: {}", dest);
    }
    // there should be at least 2 destinations - advisories -
    // 1 for the connection + 1 generic ones
    assertTrue("Should be at least 2 destinations", rb.getDestinationMap().size() > 2);
}
Also used : Destination(org.apache.activemq.broker.region.Destination) MessageConsumer(javax.jms.MessageConsumer) RegionBroker(org.apache.activemq.broker.region.RegionBroker) MessageProducer(javax.jms.MessageProducer) TemporaryTopic(javax.jms.TemporaryTopic)

Example 3 with Destination

use of org.apache.activemq.broker.region.Destination in project activemq-artemis by apache.

the class NetworkRemovesSubscriptionsTest method testWithOneSubscriber.

public void testWithOneSubscriber() throws Exception {
    TopicConnection connection = connectionFactory.createTopicConnection();
    connection.start();
    TopicSession subscriberSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    TopicSubscriber subscriber = subscriberSession.createSubscriber(topic);
    DummyMessageListener listener = new DummyMessageListener();
    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());
}
Also used : TopicSubscriber(javax.jms.TopicSubscriber) Destination(org.apache.activemq.broker.region.Destination) TopicSession(javax.jms.TopicSession) TopicConnection(javax.jms.TopicConnection)

Example 4 with Destination

use of org.apache.activemq.broker.region.Destination in project activemq-artemis by apache.

the class NetworkRemovesSubscriptionsTest method testWithSessionCloseOutsideTheLoop.

public void testWithSessionCloseOutsideTheLoop() throws Exception {
    TopicConnection connection = connectionFactory.createTopicConnection();
    connection.start();
    TopicSession subscriberSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    for (int i = 0; i < 100; i++) {
        TopicSubscriber subscriber = subscriberSession.createSubscriber(topic);
        DummyMessageListener listener = new DummyMessageListener();
        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());
}
Also used : TopicSubscriber(javax.jms.TopicSubscriber) Destination(org.apache.activemq.broker.region.Destination) TopicSession(javax.jms.TopicSession) TopicConnection(javax.jms.TopicConnection)

Example 5 with Destination

use of org.apache.activemq.broker.region.Destination in project activemq-artemis by apache.

the class NetworkRemovesSubscriptionsTest method testWithSessionAndSubsciberClose.

public void testWithSessionAndSubsciberClose() throws Exception {
    TopicConnection connection = connectionFactory.createTopicConnection();
    connection.start();
    for (int i = 0; i < 100; i++) {
        TopicSession subscriberSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        TopicSubscriber subscriber = subscriberSession.createSubscriber(topic);
        DummyMessageListener listener = new DummyMessageListener();
        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());
}
Also used : TopicSubscriber(javax.jms.TopicSubscriber) Destination(org.apache.activemq.broker.region.Destination) TopicSession(javax.jms.TopicSession) TopicConnection(javax.jms.TopicConnection)

Aggregations

Destination (org.apache.activemq.broker.region.Destination)18 MessageConsumer (javax.jms.MessageConsumer)6 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)6 TopicConnection (javax.jms.TopicConnection)5 TopicSession (javax.jms.TopicSession)5 TopicSubscriber (javax.jms.TopicSubscriber)5 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)5 Session (javax.jms.Session)4 MessageProducer (javax.jms.MessageProducer)3 TestSupport.getDestination (org.apache.activemq.TestSupport.getDestination)3 RegionBroker (org.apache.activemq.broker.region.RegionBroker)3 Subscription (org.apache.activemq.broker.region.Subscription)3 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)3 MessageIdList (org.apache.activemq.util.MessageIdList)3 ObjectName (javax.management.ObjectName)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 BytesMessage (javax.jms.BytesMessage)1