diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java b/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java index 5b167f75d5..676995a24c 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java @@ -1008,7 +1008,7 @@ public class Queue extends BaseDestination implements Task, UsageListener { public void doBrowse(List browseList, int max) { final ConnectionContext connectionContext = createConnectionContext(); try { - pageInMessages(false); + pageInMessages(!isUseCache()); List toExpire = new ArrayList(); pagedInPendingDispatchLock.writeLock().lock(); diff --git a/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java b/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java index a83b14ae55..82bbb9f357 100755 --- a/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java @@ -19,7 +19,6 @@ package org.apache.activemq; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; - import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; @@ -27,16 +26,16 @@ import javax.jms.Queue; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; - -import org.apache.activemq.broker.StubConnection; +import javax.management.ObjectName; +import javax.management.openmbean.CompositeData; +import javax.management.openmbean.TabularData; +import junit.framework.Test; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.jmx.QueueViewMBean; import org.apache.activemq.broker.region.BaseDestination; -import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.broker.region.policy.PolicyEntry; +import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.command.ConnectionInfo; -import org.apache.activemq.command.ConsumerInfo; -import org.apache.activemq.command.MessageAck; -import org.apache.activemq.command.ProducerInfo; -import org.apache.activemq.command.SessionInfo; /** * @@ -44,7 +43,11 @@ import org.apache.activemq.command.SessionInfo; public class JmsQueueBrowserTest extends JmsTestSupport { private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory .getLog(JmsQueueBrowserTest.class); - + public boolean isUseCache = false; + + public static Test suite() throws Exception { + return suite(JmsQueueBrowserTest.class); + } /** * Tests the queue browser. Browses the messages then the consumer tries to receive them. The messages should still @@ -105,13 +108,178 @@ public class JmsQueueBrowserTest extends JmsTestSupport { consumer.close(); } - + + public void initCombosForTestBatchSendBrowseReceive() { + addCombinationValues("isUseCache", new Boolean[]{Boolean.TRUE, Boolean.FALSE}); + } + + public void testBatchSendBrowseReceive() throws Exception { + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + ActiveMQQueue destination = new ActiveMQQueue("TEST"); + MessageProducer producer = session.createProducer(destination); + MessageConsumer consumer = session.createConsumer(destination); + connection.start(); + + TextMessage[] outbound = new TextMessage[10]; + for (int i=0; i<10; i++) { + outbound[i] = session.createTextMessage( i + " Message"); + }; + + // lets consume any outstanding messages from previous test runs + while (consumer.receive(1000) != null) { + } + consumer.close(); + + for (int i=0;i 0); + + assertEquals("Queue size", outbound.length, proxy.getQueueSize()); + assertEquals("Queue size", outbound.length, compdatalist.length); + assertEquals("Queue size", outbound.length, table.size()); + + + LOG.info("Send another 10"); + for (int i=0;i 0); + + assertEquals("Queue size", outbound.length*2, proxy.getQueueSize()); + assertEquals("Queue size", outbound.length*2, compdatalist.length); + assertEquals("Queue size", outbound.length * 2, table.size()); + + consumer = session.createConsumer(destination); + for (int i=0; i