use of org.apache.activemq.broker.region.Destination in project activemq-artemis by apache.
the class DurableSubscriptionActivationTest method testActivateWithExistingTopic.
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);
}
use of org.apache.activemq.broker.region.Destination in project activemq-artemis by apache.
the class DurableUnsubscribeTest method testUnsubscribe.
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());
}
use of org.apache.activemq.broker.region.Destination in project fabric8 by jboss-fuse.
the class LocalBrokerFacade method purgeQueue.
public void purgeQueue(ActiveMQDestination destination) throws Exception {
Set destinations = getManagedBroker().getQueueRegion().getDestinations(destination);
for (Iterator i = destinations.iterator(); i.hasNext(); ) {
Destination dest = (Destination) i.next();
if (dest instanceof Queue) {
Queue regionQueue = (Queue) dest;
regionQueue.purge();
}
}
}
Aggregations