@@ -734,9 +734,9 @@ private final class ListenerConsumer implements SchedulingAwareRunnable, Consume
734
734
735
735
private long lastAlertAt = this .lastReceive ;
736
736
737
- private long nackSleep = -1 ;
737
+ private long nackSleepDurationMillis = -1 ;
738
738
739
- private long nackWake ;
739
+ private long nackWakeTimeMillis ;
740
740
741
741
private int nackIndex ;
742
742
@@ -1637,9 +1637,9 @@ private void doPauseConsumerIfNecessary() {
1637
1637
}
1638
1638
1639
1639
private void resumeConsumerIfNeccessary () {
1640
- if (this .nackWake > 0 ) {
1641
- if (System .currentTimeMillis () > this .nackWake ) {
1642
- this .nackWake = 0 ;
1640
+ if (this .nackWakeTimeMillis > 0 ) {
1641
+ if (System .currentTimeMillis () > this .nackWakeTimeMillis ) {
1642
+ this .nackWakeTimeMillis = 0 ;
1643
1643
this .consumer .resume (this .pausedForNack );
1644
1644
this .logger .debug (() -> "Resumed after nack sleep: " + this .pausedForNack );
1645
1645
this .pausedForNack .clear ();
@@ -2237,7 +2237,7 @@ private void invokeBatchOnMessage(final ConsumerRecords<K, V> records, // NOSONA
2237
2237
2238
2238
invokeBatchOnMessageWithRecordsOrList (records , recordList );
2239
2239
List <ConsumerRecord <?, ?>> toSeek = null ;
2240
- if (this .nackSleep >= 0 ) {
2240
+ if (this .nackSleepDurationMillis >= 0 ) {
2241
2241
int index = 0 ;
2242
2242
toSeek = new ArrayList <>();
2243
2243
for (ConsumerRecord <K , V > record : records ) {
@@ -2247,7 +2247,7 @@ private void invokeBatchOnMessage(final ConsumerRecords<K, V> records, // NOSONA
2247
2247
}
2248
2248
}
2249
2249
if (this .producer != null || (!this .isAnyManualAck && !this .autoCommit )) {
2250
- if (this .nackSleep < 0 ) {
2250
+ if (this .nackSleepDurationMillis < 0 ) {
2251
2251
for (ConsumerRecord <K , V > record : getHighestOffsetRecords (records )) {
2252
2252
this .acks .put (record );
2253
2253
}
@@ -2391,7 +2391,7 @@ private void invokeRecordListenerInTx(final ConsumerRecords<K, V> records) {
2391
2391
if (this .commonRecordInterceptor != null ) {
2392
2392
this .commonRecordInterceptor .afterRecord (record , this .consumer );
2393
2393
}
2394
- if (this .nackSleep >= 0 ) {
2394
+ if (this .nackSleepDurationMillis >= 0 ) {
2395
2395
handleNack (records , record );
2396
2396
break ;
2397
2397
}
@@ -2475,7 +2475,7 @@ private void doInvokeWithRecords(final ConsumerRecords<K, V> records) {
2475
2475
if (this .commonRecordInterceptor != null ) {
2476
2476
this .commonRecordInterceptor .afterRecord (record , this .consumer );
2477
2477
}
2478
- if (this .nackSleep >= 0 ) {
2478
+ if (this .nackSleepDurationMillis >= 0 ) {
2479
2479
handleNack (records , record );
2480
2480
break ;
2481
2481
}
@@ -2551,8 +2551,8 @@ private boolean recordsEqual(ConsumerRecord<K, V> rec1, ConsumerRecord<K, V> rec
2551
2551
}
2552
2552
2553
2553
private void pauseForNackSleep () {
2554
- if (this .nackSleep > 0 ) {
2555
- this .nackWake = System .currentTimeMillis () + this .nackSleep ;
2554
+ if (this .nackSleepDurationMillis > 0 ) {
2555
+ this .nackWakeTimeMillis = System .currentTimeMillis () + this .nackSleepDurationMillis ;
2556
2556
Set <TopicPartition > alreadyPaused = this .consumer .paused ();
2557
2557
Collection <TopicPartition > assigned = getAssignedPartitions ();
2558
2558
if (assigned != null ) {
@@ -2572,7 +2572,7 @@ private void pauseForNackSleep() {
2572
2572
this .consumer .resume (nowPaused );
2573
2573
}
2574
2574
}
2575
- this .nackSleep = -1 ;
2575
+ this .nackSleepDurationMillis = -1 ;
2576
2576
}
2577
2577
2578
2578
/**
@@ -2667,7 +2667,7 @@ private void invokeOnMessage(final ConsumerRecord<K, V> record) {
2667
2667
checkDeser (record , SerializationUtils .KEY_DESERIALIZER_EXCEPTION_HEADER );
2668
2668
}
2669
2669
doInvokeOnMessage (record );
2670
- if (this .nackSleep < 0 && !this .isManualImmediateAck ) {
2670
+ if (this .nackSleepDurationMillis < 0 && !this .isManualImmediateAck ) {
2671
2671
ackCurrent (record );
2672
2672
}
2673
2673
}
@@ -3240,11 +3240,11 @@ public void acknowledge() {
3240
3240
}
3241
3241
3242
3242
@ Override
3243
- public void nack (long sleep ) {
3243
+ public void nack (long sleepMillis ) {
3244
3244
Assert .state (Thread .currentThread ().equals (ListenerConsumer .this .consumerThread ),
3245
3245
"nack() can only be called on the consumer thread" );
3246
- Assert .isTrue (sleep >= 0 , "sleep cannot be negative" );
3247
- ListenerConsumer .this .nackSleep = sleep ;
3246
+ Assert .isTrue (sleepMillis >= 0 , "sleepMillis cannot be negative" );
3247
+ ListenerConsumer .this .nackSleepDurationMillis = sleepMillis ;
3248
3248
synchronized (ListenerConsumer .this ) {
3249
3249
if (ListenerConsumer .this .offsetsInThisBatch != null ) {
3250
3250
ListenerConsumer .this .offsetsInThisBatch .forEach ((part , recs ) -> recs .clear ());
@@ -3288,13 +3288,13 @@ public void acknowledge() {
3288
3288
}
3289
3289
3290
3290
@ Override
3291
- public void nack (int index , long sleep ) {
3291
+ public void nack (int index , long sleepMillis ) {
3292
3292
Assert .state (Thread .currentThread ().equals (ListenerConsumer .this .consumerThread ),
3293
3293
"nack() can only be called on the consumer thread" );
3294
- Assert .isTrue (sleep >= 0 , "sleep cannot be negative" );
3294
+ Assert .isTrue (sleepMillis >= 0 , "sleepMillis cannot be negative" );
3295
3295
Assert .isTrue (index >= 0 && index < this .records .count (), "index out of bounds" );
3296
3296
ListenerConsumer .this .nackIndex = index ;
3297
- ListenerConsumer .this .nackSleep = sleep ;
3297
+ ListenerConsumer .this .nackSleepDurationMillis = sleepMillis ;
3298
3298
synchronized (ListenerConsumer .this ) {
3299
3299
if (ListenerConsumer .this .offsetsInThisBatch != null ) {
3300
3300
ListenerConsumer .this .offsetsInThisBatch .forEach ((part , recs ) -> recs .clear ());
0 commit comments