From ecb50234ec17abe5293d265b93ecda0817341da4 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Mon, 20 Nov 2006 21:40:28 +0000 Subject: [PATCH] http://issues.apache.org/activemq/browse/AMQ-1042 git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@477356 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/ActiveMQMessageConsumer.java | 3 --- .../java/org/apache/activemq/JMSConsumerTest.java | 12 +++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java index f1fcffb17f..e5b91ab6e5 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java @@ -877,9 +877,6 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC } } } - // 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); } diff --git a/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java b/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java index 427696f753..4087e2e262 100755 --- a/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java @@ -287,7 +287,8 @@ public class JMSConsumerTest extends JmsTestSupport { 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 @@ public class JMSConsumerTest extends JmsTestSupport { 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 @@ public class JMSConsumerTest extends JmsTestSupport { // 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();