ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
// ensure more than on message can be pending when full
factory.setProducerWindowSize(48*1024);
// ensure messages are spooled to disk for this consumer
ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
prefetch.setTopicPrefetch(10);
factory.setPrefetchPolicy(prefetch);
Connection consumerConnection = factory.createConnection();
consumerConnection.start();
Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);