diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/TransactedStoreUsageSuspendResumeTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/TransactedStoreUsageSuspendResumeTest.java index ebc3e373d6..99a3e9eedb 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/TransactedStoreUsageSuspendResumeTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/TransactedStoreUsageSuspendResumeTest.java @@ -16,10 +16,13 @@ */ package org.apache.activemq.bugs; +import static org.junit.Assert.assertTrue; + import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; + import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -29,6 +32,7 @@ import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.TestSupport; import org.apache.activemq.broker.BrokerService; @@ -42,9 +46,6 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import static org.junit.Assert.assertTrue; - // https://issues.apache.org/jira/browse/AMQ-4262 public class TransactedStoreUsageSuspendResumeTest { private static final Logger LOG = LoggerFactory.getLogger(TransactedStoreUsageSuspendResumeTest.class); @@ -86,13 +87,16 @@ public class TransactedStoreUsageSuspendResumeTest { do { Message message = consumer.receive(5000); if (message != null) { - session.commit(); + if ((messagesReceivedCountDown.getCount() % (MAX_MESSAGES / 5)) == 0) { + session.commit(); + } messagesReceivedCountDown.countDown(); } if (messagesReceivedCountDown.getCount() % 500 == 0) { LOG.info("remaining to receive: " + messagesReceivedCountDown.getCount()); } } while (messagesReceivedCountDown.getCount() != 0); + session.commit(); consumer.close(); session.close(); connection.close();