@@ -730,9 +730,9 @@ private final class ListenerConsumer implements SchedulingAwareRunnable, Consume
730
730
731
731
private long lastAlertAt = this .lastReceive ;
732
732
733
- private long nackSleep = -1 ;
733
+ private long nackSleepDurationMillis = -1 ;
734
734
735
- private long nackWake ;
735
+ private long nackWakeTimeMillis ;
736
736
737
737
private int nackIndex ;
738
738
@@ -1622,9 +1622,9 @@ private void doPauseConsumerIfNecessary() {
1622
1622
}
1623
1623
1624
1624
private void resumeConsumerIfNeccessary () {
1625
- if (this .nackWake > 0 ) {
1626
- if (System .currentTimeMillis () > this .nackWake ) {
1627
- this .nackWake = 0 ;
1625
+ if (this .nackWakeTimeMillis > 0 ) {
1626
+ if (System .currentTimeMillis () > this .nackWakeTimeMillis ) {
1627
+ this .nackWakeTimeMillis = 0 ;
1628
1628
this .consumer .resume (this .pausedForNack );
1629
1629
this .logger .debug (() -> "Resumed after nack sleep: " + this .pausedForNack );
1630
1630
this .pausedForNack .clear ();
@@ -2207,7 +2207,7 @@ private void invokeBatchOnMessage(final ConsumerRecords<K, V> records, // NOSONA
2207
2207
2208
2208
invokeBatchOnMessageWithRecordsOrList (records , recordList );
2209
2209
List <ConsumerRecord <?, ?>> toSeek = null ;
2210
- if (this .nackSleep >= 0 ) {
2210
+ if (this .nackSleepDurationMillis >= 0 ) {
2211
2211
int index = 0 ;
2212
2212
toSeek = new ArrayList <>();
2213
2213
for (ConsumerRecord <K , V > record : records ) {
@@ -2217,7 +2217,7 @@ private void invokeBatchOnMessage(final ConsumerRecords<K, V> records, // NOSONA
2217
2217
}
2218
2218
}
2219
2219
if (this .producer != null || (!this .isAnyManualAck && !this .autoCommit )) {
2220
- if (this .nackSleep < 0 ) {
2220
+ if (this .nackSleepDurationMillis < 0 ) {
2221
2221
for (ConsumerRecord <K , V > record : getHighestOffsetRecords (records )) {
2222
2222
this .acks .put (record );
2223
2223
}
@@ -2356,7 +2356,7 @@ private void invokeRecordListenerInTx(final ConsumerRecords<K, V> records) {
2356
2356
if (this .commonRecordInterceptor != null ) {
2357
2357
this .commonRecordInterceptor .afterRecord (record , this .consumer );
2358
2358
}
2359
- if (this .nackSleep >= 0 ) {
2359
+ if (this .nackSleepDurationMillis >= 0 ) {
2360
2360
handleNack (records , record );
2361
2361
break ;
2362
2362
}
@@ -2435,7 +2435,7 @@ private void doInvokeWithRecords(final ConsumerRecords<K, V> records) {
2435
2435
if (this .commonRecordInterceptor != null ) {
2436
2436
this .commonRecordInterceptor .afterRecord (record , this .consumer );
2437
2437
}
2438
- if (this .nackSleep >= 0 ) {
2438
+ if (this .nackSleepDurationMillis >= 0 ) {
2439
2439
handleNack (records , record );
2440
2440
break ;
2441
2441
}
@@ -2510,8 +2510,8 @@ private boolean recordsEqual(ConsumerRecord<K, V> rec1, ConsumerRecord<K, V> rec
2510
2510
}
2511
2511
2512
2512
private void pauseForNackSleep () {
2513
- if (this .nackSleep > 0 ) {
2514
- this .nackWake = System .currentTimeMillis () + this .nackSleep ;
2513
+ if (this .nackSleepDurationMillis > 0 ) {
2514
+ this .nackWakeTimeMillis = System .currentTimeMillis () + this .nackSleepDurationMillis ;
2515
2515
Set <TopicPartition > alreadyPaused = this .consumer .paused ();
2516
2516
Collection <TopicPartition > assigned = getAssignedPartitions ();
2517
2517
if (assigned != null ) {
@@ -2531,7 +2531,7 @@ private void pauseForNackSleep() {
2531
2531
this .consumer .resume (nowPaused );
2532
2532
}
2533
2533
}
2534
- this .nackSleep = -1 ;
2534
+ this .nackSleepDurationMillis = -1 ;
2535
2535
}
2536
2536
2537
2537
/**
@@ -2626,7 +2626,7 @@ private void invokeOnMessage(final ConsumerRecord<K, V> record) {
2626
2626
checkDeser (record , SerializationUtils .KEY_DESERIALIZER_EXCEPTION_HEADER );
2627
2627
}
2628
2628
doInvokeOnMessage (record );
2629
- if (this .nackSleep < 0 && !this .isManualImmediateAck ) {
2629
+ if (this .nackSleepDurationMillis < 0 && !this .isManualImmediateAck ) {
2630
2630
ackCurrent (record );
2631
2631
}
2632
2632
}
@@ -3174,11 +3174,11 @@ public void acknowledge() {
3174
3174
}
3175
3175
3176
3176
@ Override
3177
- public void nack (long sleep ) {
3177
+ public void nack (long sleepMillis ) {
3178
3178
Assert .state (Thread .currentThread ().equals (ListenerConsumer .this .consumerThread ),
3179
3179
"nack() can only be called on the consumer thread" );
3180
- Assert .isTrue (sleep >= 0 , "sleep cannot be negative" );
3181
- ListenerConsumer .this .nackSleep = sleep ;
3180
+ Assert .isTrue (sleepMillis >= 0 , "sleepMillis cannot be negative" );
3181
+ ListenerConsumer .this .nackSleepDurationMillis = sleepMillis ;
3182
3182
synchronized (ListenerConsumer .this ) {
3183
3183
if (ListenerConsumer .this .offsetsInThisBatch != null ) {
3184
3184
ListenerConsumer .this .offsetsInThisBatch .forEach ((part , recs ) -> recs .clear ());
@@ -3221,13 +3221,13 @@ public void acknowledge() {
3221
3221
}
3222
3222
3223
3223
@ Override
3224
- public void nack (int index , long sleep ) {
3224
+ public void nack (int index , long sleepMillis ) {
3225
3225
Assert .state (Thread .currentThread ().equals (ListenerConsumer .this .consumerThread ),
3226
3226
"nack() can only be called on the consumer thread" );
3227
- Assert .isTrue (sleep >= 0 , "sleep cannot be negative" );
3227
+ Assert .isTrue (sleepMillis >= 0 , "sleepMillis cannot be negative" );
3228
3228
Assert .isTrue (index >= 0 && index < this .records .count (), "index out of bounds" );
3229
3229
ListenerConsumer .this .nackIndex = index ;
3230
- ListenerConsumer .this .nackSleep = sleep ;
3230
+ ListenerConsumer .this .nackSleepDurationMillis = sleepMillis ;
3231
3231
synchronized (ListenerConsumer .this ) {
3232
3232
if (ListenerConsumer .this .offsetsInThisBatch != null ) {
3233
3233
ListenerConsumer .this .offsetsInThisBatch .forEach ((part , recs ) -> recs .clear ());
0 commit comments