File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
test/src/com/rabbitmq/client/test/functional Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 2020import com .rabbitmq .client .AMQP ;
2121import com .rabbitmq .client .GetResponse ;
2222import com .rabbitmq .client .QueueingConsumer ;
23+ import com .rabbitmq .client .QueueingConsumer .Delivery ;
2324import com .rabbitmq .client .test .BrokerTestCase ;
2425
2526import 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 ());
You can’t perform that action at this time.
0 commit comments