use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class ThreeBrokerQueueNetworkTest method testNoDuplicateQueueSubs.
public void testNoDuplicateQueueSubs() throws Exception {
bridgeAllBrokers("default", 3, true);
startAllBrokers();
waitForBridgeFormation();
// Setup destination
Destination dest = createDestination("TEST.FOO", false);
// Setup consumers
String brokerName = "BrokerA";
MessageConsumer consumer = createConsumer(brokerName, dest);
// wait for advisories
Thread.sleep(2000);
// verify there is one consumer on each broker, no cycles
Collection<BrokerItem> brokerList = brokers.values();
for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
BrokerService broker = i.next().broker;
verifyConsumerCount(broker, 1, dest);
}
consumer.close();
// wait for advisories
Thread.sleep(2000);
// verify there is no more consumers
for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
BrokerService broker = i.next().broker;
verifyConsumerCount(broker, 0, dest);
}
}
use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class ThreeBrokerQueueNetworkTest method testNoDuplicateQueueSubsHasLowestPriority.
public void testNoDuplicateQueueSubsHasLowestPriority() throws Exception {
boolean suppressQueueDuplicateSubscriptions = true;
boolean decreaseNetworkConsumerPriority = true;
bridgeAllBrokers("default", 3, suppressQueueDuplicateSubscriptions, decreaseNetworkConsumerPriority);
// Setup destination
final Destination dest = createDestination("TEST.FOO", false);
// delay the advisory messages so that one can percolate fully (cyclically) before the other
BrokerItem brokerB = brokers.get("BrokerA");
brokerB.broker.setPlugins(new BrokerPlugin[] { new BrokerPlugin() {
@Override
public Broker installPlugin(Broker broker) throws Exception {
return new BrokerFilter(broker) {
final AtomicInteger count = new AtomicInteger();
@Override
public void preProcessDispatch(MessageDispatch messageDispatch) {
if (messageDispatch.getDestination().getPhysicalName().contains("ActiveMQ.Advisory.Consumer")) {
// lets delay the first advisory
if (count.getAndIncrement() == 0) {
LOG.info("Sleeping on first advisory: " + messageDispatch);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
super.postProcessDispatch(messageDispatch);
}
};
}
} });
startAllBrokers();
waitForBridgeFormation();
// Setup consumers
String brokerName = "BrokerA";
createConsumer(brokerName, dest);
// wait for advisories
Thread.sleep(5000);
// verify there is one consumer on each broker, no cycles
Collection<BrokerItem> brokerList = brokers.values();
for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
BrokerService broker = i.next().broker;
verifyConsumerCount(broker, 1, dest);
if (!brokerName.equals(broker.getBrokerName())) {
verifyConsumePriority(broker, ConsumerInfo.NETWORK_CONSUMER_PRIORITY, dest);
}
}
}
use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class ThreeBrokerStompTemporaryQueueTest method testStompTemporaryQueue.
public void testStompTemporaryQueue() throws Exception {
// Setup broker networks
bridgeAndConfigureBrokers("BrokerA", "BrokerB");
bridgeAndConfigureBrokers("BrokerA", "BrokerC");
bridgeAndConfigureBrokers("BrokerB", "BrokerA");
bridgeAndConfigureBrokers("BrokerB", "BrokerC");
bridgeAndConfigureBrokers("BrokerC", "BrokerA");
bridgeAndConfigureBrokers("BrokerC", "BrokerB");
startAllBrokers();
waitForBridgeFormation();
Thread.sleep(1000);
stompConnection = new StompConnection();
stompConnection.open("localhost", 61614);
// Creating a temp queue
stompConnection.sendFrame("CONNECT\n" + "login:system\n" + "passcode:manager\n\n" + Stomp.NULL);
StompFrame frame = stompConnection.receive();
assertTrue(frame.toString().startsWith("CONNECTED"));
stompConnection.subscribe("/temp-queue/meaningless", "auto");
stompConnection.send("/temp-queue/meaningless", "Hello World");
frame = stompConnection.receive(3000);
assertEquals("Hello World", frame.getBody());
Thread.sleep(1000);
assertEquals("Destination", 1, brokers.get("BrokerA").broker.getAdminView().getTemporaryQueues().length);
assertEquals("Destination", 1, brokers.get("BrokerB").broker.getAdminView().getTemporaryQueues().length);
assertEquals("Destination", 1, brokers.get("BrokerC").broker.getAdminView().getTemporaryQueues().length);
int advisoryTopicsForTempQueues;
advisoryTopicsForTempQueues = countTopicsByName("BrokerA", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should be present", 1, advisoryTopicsForTempQueues);
advisoryTopicsForTempQueues = countTopicsByName("BrokerB", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should be present", 1, advisoryTopicsForTempQueues);
advisoryTopicsForTempQueues = countTopicsByName("BrokerC", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should be present", 1, advisoryTopicsForTempQueues);
stompConnection.disconnect();
Thread.sleep(1000);
advisoryTopicsForTempQueues = countTopicsByName("BrokerA", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should have been deleted", 0, advisoryTopicsForTempQueues);
advisoryTopicsForTempQueues = countTopicsByName("BrokerB", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should have been deleted", 0, advisoryTopicsForTempQueues);
advisoryTopicsForTempQueues = countTopicsByName("BrokerC", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should have been deleted", 0, advisoryTopicsForTempQueues);
LOG.info("Restarting brokerA");
BrokerItem brokerItem = brokers.remove("BrokerA");
if (brokerItem != null) {
brokerItem.destroy();
}
BrokerService restartedBroker = createAndConfigureBroker(new URI("broker:(tcp://localhost:61616,stomp://localhost:61613)/BrokerA"));
bridgeAndConfigureBrokers("BrokerA", "BrokerB");
bridgeAndConfigureBrokers("BrokerA", "BrokerC");
restartedBroker.start();
waitForBridgeFormation();
Thread.sleep(3000);
assertEquals("Destination", 0, brokers.get("BrokerA").broker.getAdminView().getTemporaryQueues().length);
assertEquals("Destination", 0, brokers.get("BrokerB").broker.getAdminView().getTemporaryQueues().length);
assertEquals("Destination", 0, brokers.get("BrokerC").broker.getAdminView().getTemporaryQueues().length);
advisoryTopicsForTempQueues = countTopicsByName("BrokerA", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should have been deleted", 0, advisoryTopicsForTempQueues);
advisoryTopicsForTempQueues = countTopicsByName("BrokerB", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should have been deleted", 0, advisoryTopicsForTempQueues);
advisoryTopicsForTempQueues = countTopicsByName("BrokerC", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should have been deleted", 0, advisoryTopicsForTempQueues);
}
use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class ThreeBrokerStompTemporaryQueueTest method createAndConfigureBroker.
private BrokerService createAndConfigureBroker(URI uri) throws Exception {
BrokerService broker = createBroker(uri);
configurePersistenceAdapter(broker);
return broker;
}
use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.
the class QueueMemoryFullMultiBrokersTest method setUp.
@Override
public void setUp() throws Exception {
super.setAutoFail(true);
super.setUp();
messageSize = 1024;
// Setup n brokers
for (int i = 1; i <= BROKER_COUNT; i++) {
createBroker(new URI("broker:()/Broker" + i + "?persistent=false&useJmx=false"));
}
BrokerService broker2 = brokers.get("Broker2").broker;
applyMemoryLimitPolicy(broker2);
}
Aggregations