use of org.apache.activemq.transport.stomp.StompConnection 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);
}
Aggregations