Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void testOptimizedConsumer() {
- try {
- logger.info(getDate() + " starting test...");
- Connection qConnection = null;
- Session session = null;
- MessageConsumer messageConsumer = null;
- String broker = "failover:(tcp://cache07:61616)";
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker);
- connectionFactory.setOptimizeAcknowledge(true);
- connectionFactory.setAlwaysSessionAsync(false);
- qConnection = connectionFactory.createConnection();
- qConnection.start();
- session = qConnection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
- Destination destination = session.createQueue("benchmarks2");
- messageConsumer = session.createConsumer(destination);
- TextMessage messageReceived = null;
- int i = 0;
- int numberOfMessages = 100000;
- while (i < numberOfMessages) {
- i++;
- messageReceived = (TextMessage) messageConsumer.receive(10000);
- String msg = messageReceived.getText();
- logger.info(msg);
- }
- logger.info(getDate() + " optimized consumer test over. dequeued: " + numberOfMessages + " messages");
- } catch (JMSException e) {
- logger.error(e.toString(), e);
- throw new RuntimeException(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment