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