@@ -113,4 +113,36 @@ public void testMultiNack() throws Exception {
113113 expectError (AMQP .PRECONDITION_FAILED );
114114 }
115115
116+ public void testNackAll () throws Exception {
117+ String q =
118+ channel .queueDeclare ("" , false , true , false , null ).getQueue ();
119+
120+ byte [] m1 = "1" .getBytes ();
121+ byte [] m2 = "2" .getBytes ();
122+ byte [] m3 = "3" .getBytes ();
123+ byte [] m4 = "4" .getBytes ();
124+
125+ basicPublishVolatile (m1 , q );
126+ basicPublishVolatile (m2 , q );
127+ basicPublishVolatile (m3 , q );
128+ basicPublishVolatile (m4 , q );
129+
130+ checkDelivery (channel .basicGet (q , false ), m1 , false );
131+ checkDelivery (channel .basicGet (q , false ), m2 , false );
132+ checkDelivery (channel .basicGet (q , false ), m3 , false );
133+ checkDelivery (channel .basicGet (q , false ), m4 , false );
134+
135+ // nack all
136+ channel .basicNack (0 , true , true );
137+
138+ QueueingConsumer c = new QueueingConsumer (secondaryChannel );
139+ String consumerTag = secondaryChannel .basicConsume (q , true , c );
140+
141+ checkDelivery (c .nextDelivery (), m4 , true );
142+ checkDelivery (c .nextDelivery (), m3 , true );
143+ checkDelivery (c .nextDelivery (), m2 , true );
144+ checkDelivery (c .nextDelivery (), m1 , true );
145+
146+ secondaryChannel .basicCancel (consumerTag );
147+ }
116148}
0 commit comments