@@ -36,10 +36,10 @@ public class Consumer extends AgentBase implements Runnable {
3636 private static final Logger LOGGER = LoggerFactory .getLogger (Consumer .class );
3737
3838 private static final AckNackOperation ACK_OPERATION =
39- (ch , envelope , multiple ) -> ch .basicAck (envelope .getDeliveryTag (), multiple );
39+ (ch , envelope , multiple , requeue ) -> ch .basicAck (envelope .getDeliveryTag (), multiple );
4040
4141 private static final AckNackOperation NACK_OPERATION =
42- (ch , envelope , multiple ) -> ch .basicNack (envelope .getDeliveryTag (), multiple , true );
42+ (ch , envelope , multiple , requeue ) -> ch .basicNack (envelope .getDeliveryTag (), multiple , requeue );
4343 static final String STOP_REASON_CONSUMER_REACHED_MESSAGE_LIMIT = "Consumer reached message limit" ;
4444
4545 private volatile ConsumerImpl q ;
@@ -48,6 +48,7 @@ public class Consumer extends AgentBase implements Runnable {
4848 private final int txSize ;
4949 private final boolean autoAck ;
5050 private final int multiAckEvery ;
51+ private final boolean requeue ;
5152 private final Stats stats ;
5253 private final int msgLimit ;
5354 private final Map <String , String > consumerTagBranchMap = Collections .synchronizedMap (new HashMap <>());
@@ -81,6 +82,7 @@ public Consumer(ConsumerParameters parameters) {
8182 this .txSize = parameters .getTxSize ();
8283 this .autoAck = parameters .isAutoAck ();
8384 this .multiAckEvery = parameters .getMultiAckEvery ();
85+ this .requeue = parameters .isRequeue ();
8486 this .stats = parameters .getStats ();
8587 this .msgLimit = parameters .getMsgLimit ();
8688 this .timestampProvider = parameters .getTimestampProvider ();
@@ -266,9 +268,9 @@ private void ackIfNecessary(Envelope envelope, int currentMessageCount, final Ch
266268 if (!autoAck ) {
267269 dealWithWriteOperation (() -> {
268270 if (multiAckEvery == 0 ) {
269- ackNackOperation .apply (ch , envelope , false );
271+ ackNackOperation .apply (ch , envelope , false , requeue );
270272 } else if (currentMessageCount % multiAckEvery == 0 ) {
271- ackNackOperation .apply (ch , envelope , true );
273+ ackNackOperation .apply (ch , envelope , true , requeue );
272274 }
273275 }, recoveryProcess );
274276 }
@@ -473,7 +475,7 @@ public boolean simulateLatency() {
473475 @ FunctionalInterface
474476 private interface AckNackOperation {
475477
476- void apply (Channel channel , Envelope envelope , boolean multiple ) throws IOException ;
478+ void apply (Channel channel , Envelope envelope , boolean multiple , boolean requeue ) throws IOException ;
477479
478480 }
479481
0 commit comments