Skip to content

Commit 3616891

Browse files
author
Tim Watson
committed
add test case for eagerly dropping expired messages
1 parent 7d2bcb0 commit 3616891

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/src/com/rabbitmq/client/test/functional/PerMessageTTL.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.rabbitmq.client.test.functional;
1919

2020
import com.rabbitmq.client.AMQP;
21+
import com.rabbitmq.client.QueueingConsumer;
2122
import com.rabbitmq.client.MessageProperties;
2223

2324
import java.io.IOException;
@@ -41,4 +42,20 @@ protected AMQP.Queue.DeclareOk declareQueue(String name, Object ttlValue) throws
4142
return this.channel.queueDeclare(name, false, true, false, null);
4243
}
4344

45+
public void testExpiryWhenConsumerIsLateToTheParty() throws Exception {
46+
declareAndBindQueue(3000);
47+
48+
publish(MSG[0]);
49+
this.sessionTTL = 30 * 1000;
50+
publish(MSG[1]);
51+
52+
Thread.sleep(5000);
53+
54+
QueueingConsumer c = new QueueingConsumer(channel);
55+
channel.basicConsume(TTL_QUEUE_NAME, c);
56+
57+
assertNotNull("Message unexpectedly expired", c.nextDelivery(100));
58+
assertNull("Message should have been expired!!", c.nextDelivery(100));
59+
}
60+
4461
}

0 commit comments

Comments
 (0)