diff --git a/activemq-core/src/test/java/org/apache/activemq/usecases/UnlimitedEnqueueTest.java b/activemq-core/src/test/java/org/apache/activemq/usecases/UnlimitedEnqueueTest.java index 3366174723..da5b6b0b01 100644 --- a/activemq-core/src/test/java/org/apache/activemq/usecases/UnlimitedEnqueueTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/usecases/UnlimitedEnqueueTest.java @@ -37,14 +37,21 @@ import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.FilePendingQueueMessageStoragePolicy; import org.apache.activemq.broker.region.policy.PolicyEntry; import org.apache.activemq.broker.region.policy.PolicyMap; +import org.apache.activemq.util.Wait; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.assertTrue; public class UnlimitedEnqueueTest { + private static final Logger LOG = LoggerFactory.getLogger(UnlimitedEnqueueTest.class); BrokerService brokerService = null; final long numMessages = 50000; final long numThreads = 10; + final int payLoadSize = 100*1024; @Test public void testEnqueueIsOnlyLimitedByDisk() throws Exception { @@ -52,9 +59,15 @@ public class UnlimitedEnqueueTest { for (int i=0; i 1; + } + }, TimeUnit.MINUTES.toMillis(4))); + executor.shutdownNow(); } @Before @@ -65,6 +78,8 @@ public class UnlimitedEnqueueTest { // optional, reduce the usage limit so that spooling will occur faster brokerService.getSystemUsage().getMemoryUsage().setLimit(10 * 1024 * 1024); + brokerService.getSystemUsage().getTempUsage().setLimit(numMessages * payLoadSize * 2); + PolicyMap policyMap = new PolicyMap(); List entries = new ArrayList(); PolicyEntry policy = new PolicyEntry(); @@ -99,13 +114,13 @@ public class UnlimitedEnqueueTest { try { Connection conn = factory.createConnection(); conn.start(); + byte[] bytes = new byte[payLoadSize]; for (int i = 0; i < numberOfMessages; i++) { Session session = conn.createSession(false,Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue("test-queue"); MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.PERSISTENT); BytesMessage message = session.createBytesMessage(); - byte[] bytes = new byte[1024*10]; message.writeBytes(bytes); try { producer.send(message); @@ -115,7 +130,7 @@ public class UnlimitedEnqueueTest { session.close(); } } catch (JMSException e) { - throw new RuntimeException(e); + // expect interrupted exception on shutdownNow } } }