activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r477356 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/ActiveMQMessageConsumer.java test/java/org/apache/activemq/JMSConsumerTest.java
Date Mon, 20 Nov 2006 21:40:29 GMT
Author: chirino
Date: Mon Nov 20 13:40:28 2006
New Revision: 477356

URL: http://svn.apache.org/viewvc?view=rev&rev=477356
Log:
http://issues.apache.org/activemq/browse/AMQ-1042

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java?view=diff&rev=477356&r1=477355&r2=477356
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
Mon Nov 20 13:40:28 2006
@@ -877,9 +877,6 @@
 	                }
 	            }
             }
-            // yeild here so that a thread trying to stop unconsumedMessages has 
-            // a chance of getting prioritized head of this thread that is in a dispatch
loop.
-            Thread.yield();            
         } catch (Exception e) {
         	session.connection.onAsyncException(e);
         }

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java?view=diff&rev=477356&r1=477355&r2=477356
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java
Mon Nov 20 13:40:28 2006
@@ -287,7 +287,8 @@
     public void testMessageListenerUnackedWithPrefetch1StayInQueue() throws Exception {
 
         final AtomicInteger counter = new AtomicInteger(0);
-        final CountDownLatch done = new CountDownLatch(1);
+        final CountDownLatch sendDone = new CountDownLatch(1);
+        final CountDownLatch got2Done = new CountDownLatch(1);
 
         // Set prefetch to 1
         connection.getPrefetchPolicy().setAll(1);
@@ -309,8 +310,9 @@
                     counter.incrementAndGet();
                     m.acknowledge();
                     if( counter.get()==2 ) {
-                            done.countDown();
-                            Thread.sleep(500);
+                    	sendDone.await();
+                        connection.close();
+                        got2Done.countDown();
                     }
                 } catch (Throwable e) {
                     e.printStackTrace();
@@ -320,10 +322,10 @@
 
         // Send the messages
         sendMessages(session, destination, 4);
+        sendDone.countDown();
         
         // Wait for first 2 messages to arrive.
-        assertTrue(done.await(100000, TimeUnit.MILLISECONDS));
-        connection.close();
+        assertTrue(got2Done.await(100000, TimeUnit.MILLISECONDS));
 
         // Re-start connection.
         connection = (ActiveMQConnection) factory.createConnection();



Mime
View raw message