activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r903758 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
Date Wed, 27 Jan 2010 17:46:09 GMT
Author: gtully
Date: Wed Jan 27 17:46:08 2010
New Revision: 903758

URL: http://svn.apache.org/viewvc?rev=903758&view=rev
Log:
resolve intermitent failure on loaded machines, consumer could complete before producer thread
got to do any work at all

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java?rev=903758&r1=903757&r2=903758&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
Wed Jan 27 17:46:08 2010
@@ -17,7 +17,11 @@
 package org.apache.activemq.bugs;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import java.io.File;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;
@@ -80,6 +84,7 @@
         final Connection producerConnection = factory.createConnection();
         producerConnection.start();
 
+        final CountDownLatch producerHasSentTenMessages = new CountDownLatch(10);
         Thread producingThread = new Thread("Producing thread") {
             @Override
             public void run() {
@@ -92,10 +97,12 @@
 
                         producer.send(message);
                         messagesSent.incrementAndGet();
+                        producerHasSentTenMessages.countDown();
                         Thread.sleep(10);
-                        LOG.info("Sent Message " + idx);
-                        LOG.info("Temp Store Usage " + broker.getSystemUsage().getTempUsage().getUsage());
-
+                        if (idx != 0 && idx%100 == 0) {
+                            LOG.info("Sent Message " + idx);
+                            LOG.info("Temp Store Usage " + broker.getSystemUsage().getTempUsage().getUsage());
+                        }
                     }
                     producer.close();
                     session.close();
@@ -106,12 +113,16 @@
         };
         producingThread.start();
 
+        assertTrue("producer has sent 10 in a reasonable time", producerHasSentTenMessages.await(30,
TimeUnit.SECONDS));
+        
         int count = 0;
 
         Message m = null;
         while ((m = consumer.receive(messageReceiveTimeout)) != null) {
             count++;
-            LOG.info("Recieved Message (" + count + "):" + m);
+            if (count != 0 && count%10 == 0) {
+                LOG.info("Recieved Message (" + count + "):" + m);
+            }
             messagesConsumed.incrementAndGet();
             try {
                 Thread.sleep(100);
@@ -120,19 +131,13 @@
             }
         }
 
-        LOG.info("Connection Timeout: Retrying");
-
-        // session.close();
-        // consumerConnection.close();
-        //
-        // consumerConnection2.start();
-        // session2 = consumerConnection2.createSession(false,
-        // Session.AUTO_ACKNOWLEDGE);
-        // consumer = session2.createConsumer(destination);
+        LOG.info("Connection Timeout: Retrying.. count: " + count);
 
         while ((m = consumer.receive(messageReceiveTimeout)) != null) {
             count++;
-            LOG.info("Recieved Message (" + count + "):" + m);
+            if (count != 0 && count%10 == 0) {
+                LOG.info("Recieved Message (" + count + "):" + m);
+            }
             messagesConsumed.incrementAndGet();
             try {
                 Thread.sleep(100);



Mime
View raw message