Skip to content

Commit a98393c

Browse files
author
Emile Joubert
committed
Merge bug21854 into default
2 parents d4d1162 + 6ae0713 commit a98393c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,40 @@ public void testQueuePurge() throws IOException {
6767
deleteExchangeAndQueue(binding);
6868
}
6969

70+
/**
71+
* See bug 21854:
72+
* "When Queue.Purge is called, sent-but-unacknowledged messages are no
73+
* longer purged, even if the channel they were sent down is not
74+
* (Tx-)transacted."
75+
*/
76+
public void testUnackedPurge() throws IOException {
77+
Binding binding = setupExchangeBindings(false);
78+
channel.basicPublish(binding.x, binding.k, null, payload);
79+
80+
GetResponse response = channel.basicGet(binding.q, false);
81+
assertFalse(response.getEnvelope().isRedeliver());
82+
assertNotNull("The response SHOULD NOT BE null", response);
83+
84+
// If we purge the queue the unacked message should still be there on
85+
// recover.
86+
channel.queuePurge(binding.q);
87+
response = channel.basicGet(binding.q, true);
88+
assertNull("The response SHOULD BE null", response);
89+
90+
channel.basicRecoverAsync(true);
91+
response = channel.basicGet(binding.q, false);
92+
assertTrue(response.getEnvelope().isRedeliver());
93+
assertNotNull("The response SHOULD NOT BE null", response);
94+
95+
// If we recover then purge the message should go away
96+
channel.basicRecoverAsync(true);
97+
channel.queuePurge(binding.q);
98+
response = channel.basicGet(binding.q, true);
99+
assertNull("The response SHOULD BE null", response);
100+
101+
deleteExchangeAndQueue(binding);
102+
}
103+
70104
/**
71105
* This tests whether when you delete an exchange, that any
72106
* bindings attached to it are deleted as well.

0 commit comments

Comments
 (0)