Skip to content

Commit 77c5f91

Browse files
committed
test x-message-ttl=0 behaviour
1 parent e0e92b7 commit 77c5f91

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.rabbitmq.client.AMQP;
2121
import com.rabbitmq.client.GetResponse;
2222
import com.rabbitmq.client.QueueingConsumer;
23+
import com.rabbitmq.client.QueueingConsumer.Delivery;
2324
import com.rabbitmq.client.test.BrokerTestCase;
2425

2526
import java.io.IOException;
@@ -192,6 +193,25 @@ public void testExpiryWithRequeueAfterConsume() throws Exception {
192193
assertNull("Requeued message not expired", get());
193194
}
194195

196+
public void testZeroTTLDelivery() throws Exception {
197+
declareAndBindQueue(0);
198+
199+
// when there is no consumer, message should expire
200+
publish(MSG[0]);
201+
assertNull(get());
202+
203+
// when there is a consumer, message should be delivered
204+
QueueingConsumer c = new QueueingConsumer(channel);
205+
channel.basicConsume(TTL_QUEUE_NAME, c);
206+
publish(MSG[0]);
207+
Delivery d = c.nextDelivery(100);
208+
assertNotNull(d);
209+
210+
// requeued messages should expire
211+
channel.basicReject(d.getEnvelope().getDeliveryTag(), true);
212+
assertNull(c.nextDelivery(100));
213+
}
214+
195215
private String get() throws IOException {
196216
GetResponse response = basicGet(TTL_QUEUE_NAME);
197217
return response == null ? null : new String(response.getBody());

0 commit comments

Comments
 (0)