Source:
public void test() throws Throwable { executeCommand("bundle:list"); withinReason(new Callable<Boolean>() { @Override public Boolean call() throws Exception { assertTrue("artemis bundle installed", verifyBundleInstalled("artemis-server-osgi")); return true; } }); Object service = waitForService("(objectClass=org.apache.activemq.artemis.core.server.ActiveMQServer)", 30000); assertNotNull(service); LOG.info("have service " + service); executeCommand("service:list -n"); Connection connection = null; try { JmsConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:5672"); connection = factory.createConnection(USER, PASSWORD); connection.start(); QueueSession sess = (QueueSession) connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); Queue queue = sess.createQueue("exampleQueue"); MessageProducer producer = sess.createProducer(queue); producer.send(sess.createTextMessage("TEST")); Queue managementQueue = sess.createQueue("activemq.management"); QueueRequestor requestor = new QueueRequestor(sess, managementQueue); connection.start(); TextMessage m = sess.createTextMessage(); m.setStringProperty("_AMQ_ResourceName", "broker"); m.setStringProperty("_AMQ_OperationName", "getQueueNames"); m.setText("[\"ANYCAST\"]"); Message reply = requestor.request(m); String json = ((TextMessage) reply).getText(); JsonArray array = Json.createReader(new StringReader(json)).readArray(); List<JsonString> queues = (List<JsonString>) array.get(0); assertNotNull(queues); System.out.println(queues.stream().map(JsonString::getString).collect(Collectors.joining(", ", "Queues: ", ""))); MessageConsumer consumer = sess.createConsumer(queue); Message msg = consumer.receive(5000); assertNotNull(msg); } finally { if (connection != null) { connection.close(); } } }

Target:
public void test() throws Throwable { executeCommand("bundle:list"); withinReason(new Callable<Boolean>() { @Override public Boolean call() throws Exception { assertTrue("artemis bundle installed", verifyBundleInstalled("artemis-server-osgi")); return true; } }); Object service = waitForService("(objectClass=org.apache.activemq.artemis.core.server.ActiveMQServer)", 30000); assertNotNull(service); LOG.info("have service " + service); executeCommand("service:list -n"); Connection connection = null; try { JmsConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:5672"); connection = factory.createConnection(USER, PASSWORD); connection.start(); QueueSession sess = (QueueSession) connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); Queue queue = sess.createQueue("exampleQueue"); MessageProducer producer = sess.createProducer(queue); producer.send(sess.createTextMessage("TEST")); try (QueueBrowser browser = sess.createBrowser(queue)) { Enumeration messages = browser.getEnumeration(); while (messages.hasMoreElements()) { messages.nextElement(); } } Queue managementQueue = sess.createQueue("activemq.management"); QueueRequestor requestor = new QueueRequestor(sess, managementQueue); connection.start(); TextMessage m = sess.createTextMessage(); m.setStringProperty("_AMQ_ResourceName", "broker"); m.setStringProperty("_AMQ_OperationName", "getQueueNames"); m.setText("[\"ANYCAST\"]"); Message reply = requestor.request(m); String json = ((TextMessage) reply).getText(); JsonArray array = Json.createReader(new StringReader(json)).readArray(); List<JsonString> queues = (List<JsonString>) array.get(0); assertNotNull(queues); assertFalse(queues.isEmpty()); MessageConsumer consumer = sess.createConsumer(queue); Message msg = consumer.receive(5000); assertNotNull(msg); } finally { if (connection != null) { connection.close(); } } }