Skip to content

Commit 0347d67

Browse files
committed
merge bug25107 into default
2 parents c7d0e82 + 9ec5358 commit 0347d67

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import com.rabbitmq.client.AMQP;
44
import com.rabbitmq.client.Channel;
5+
import com.rabbitmq.client.DefaultConsumer;
6+
import com.rabbitmq.client.Envelope;
57
import com.rabbitmq.client.GetResponse;
8+
import com.rabbitmq.client.MessageProperties;
69
import com.rabbitmq.client.QueueingConsumer;
710
import com.rabbitmq.client.QueueingConsumer.Delivery;
811
import com.rabbitmq.client.test.BrokerTestCase;
@@ -15,6 +18,8 @@
1518
import java.util.List;
1619
import java.util.Map;
1720
import java.util.concurrent.Callable;
21+
import java.util.concurrent.CountDownLatch;
22+
import java.util.concurrent.TimeUnit;
1823

1924
public class DeadLetterExchange extends BrokerTestCase {
2025
public static final String DLX = "dead.letter.exchange";
@@ -266,6 +271,28 @@ public void testDeadLetterSelf() throws Exception {
266271
consumeN(TEST_QUEUE_NAME, 0, WithResponse.NULL);
267272
}
268273

274+
public void testDeadLetterCycle() throws Exception {
275+
// testDeadLetterTwice and testDeadLetterSelf both test that we drop
276+
// messages in pure-expiry cycles. So we just need to test that
277+
// non-pure-expiry cycles do not drop messages.
278+
279+
declareQueue("queue1", "", "queue2", null, 1);
280+
declareQueue("queue2", "", "queue1", null, 0);
281+
282+
channel.basicPublish("", "queue1", MessageProperties.BASIC, "".getBytes());
283+
final CountDownLatch latch = new CountDownLatch(10);
284+
channel.basicConsume("queue2", false,
285+
new DefaultConsumer(channel) {
286+
@Override
287+
public void handleDelivery(String consumerTag, Envelope envelope,
288+
AMQP.BasicProperties properties, byte[] body) throws IOException {
289+
channel.basicReject(envelope.getDeliveryTag(), false);
290+
latch.countDown();
291+
}
292+
});
293+
assertTrue(latch.await(10, TimeUnit.SECONDS));
294+
}
295+
269296
public void testDeadLetterNewRK() throws Exception {
270297
declareQueue(TEST_QUEUE_NAME, DLX, "test-other", null, 1);
271298

0 commit comments

Comments
 (0)