From 0456f0ffca2b7d2981a2de043b7635ff606dc62b Mon Sep 17 00:00:00 2001 From: Aidan Skinner Date: Thu, 22 Jan 2009 12:19:47 +0000 Subject: QPID-1418: Destroy and recreate consumer once all messages are sent so that they have enough time to expire. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@736618 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/server/queue/TimeToLiveTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'qpid/java') diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java index 02db795534..834222fcc2 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java @@ -55,8 +55,13 @@ public class TimeToLiveTest extends QpidTestCase Session clientSession = clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = clientSession.createQueue(QUEUE); - + + // Create then close the consumer so the queue is actually created + // Closing it then reopening it ensures that the consumer shouldn't get messages + // which should have expired and allows a shorter sleep period. See QPID-1418 + MessageConsumer consumer = clientSession.createConsumer(queue); + consumer.close(); //Create Producer Connection producerConnection = getConnection(); @@ -82,10 +87,11 @@ public class TimeToLiveTest extends QpidTestCase producer.setTimeToLive(0L); producer.send(nextMessage(String.valueOf(msg), false, producerSession, producer)); - try + consumer = clientSession.createConsumer(queue); + try { // Sleep to ensure TTL reached - Thread.sleep(2000); + Thread.sleep(TIME_TO_LIVE); } catch (InterruptedException e) { -- cgit v1.2.1