Here are the examples of the java api class org.apache.activemq.broker.ProgressPrinter taken from open source projects.
1. LoadTester#testQueueSendThenAddConsumer()
Project: activemq-artemis
File: LoadTester.java
File: LoadTester.java
public void testQueueSendThenAddConsumer() throws Exception { ProgressPrinter printer = new ProgressPrinter(produceCount, 20); ActiveMQDestination destination = new ActiveMQQueue("TEST"); connection.setUseCompression(false); connection.getPrefetchPolicy().setAll(10); connection.start(); Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE); MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.PERSISTENT); LOG.info("Sending " + produceCount + " messages that are " + (messageSize / 1024.0) + "k large, for a total of " + (produceCount * messageSize / (1024.0 * 1024.0)) + " megs of data."); // Send a message to the broker. long start = System.currentTimeMillis(); for (int i = 0; i < produceCount; i++) { printer.increment(); BytesMessage msg = session.createBytesMessage(); msg.writeBytes(new byte[messageSize]); producer.send(msg); } long end1 = System.currentTimeMillis(); LOG.info("Produced messages/sec: " + (produceCount * 1000.0 / (end1 - start))); printer = new ProgressPrinter(produceCount, 10); start = System.currentTimeMillis(); MessageConsumer consumer = session.createConsumer(destination); for (int i = 0; i < produceCount; i++) { printer.increment(); assertNotNull("Getting message: " + i, consumer.receive(20000)); } end1 = System.currentTimeMillis(); LOG.info("Consumed messages/sec: " + (produceCount * 1000.0 / (end1 - start))); }