activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r906104 - /activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
Date Wed, 03 Feb 2010 16:13:46 GMT
Author: dejanb
Date: Wed Feb  3 16:13:46 2010
New Revision: 906104

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

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

Modified: activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java?rev=906104&r1=906103&r2=906104&view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
(original)
+++ activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
Wed Feb  3 16:13:46 2010
@@ -18,7 +18,10 @@
 
 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;
@@ -81,6 +84,7 @@
         final Connection producerConnection = factory.createConnection();
         producerConnection.start();
 
+        final CountDownLatch producerHasSentTenMessages = new CountDownLatch(10);
         Thread producingThread = new Thread("Producing thread") {
             public void run() {
                 try {
@@ -92,10 +96,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 +112,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 +130,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