1. Only log an ERROR on the first encountered exception from the callback.
2. Wrap the exception message with the first thrown message information, and throw the exception whenever `checkException` is called.
Therefore, for the `store.put` call, it will throw a `KafkaException` with the error message a bit more intuitive.
Author: Guozhang Wang <wangguoz@gmail.com>
Reviewers: Xavier Léauté <xavier@confluent.io>, Matthias J. Sax <matthias@confluent.io>, Damian Guy <damian.guy@gmail.com>
Closes#3534 from guozhangwang/K5006-exception-record-collector
@ -44,8 +45,8 @@ public class RecordCollectorImpl implements RecordCollector {
@@ -44,8 +45,8 @@ public class RecordCollectorImpl implements RecordCollector {
@ -106,11 +107,15 @@ public class RecordCollectorImpl implements RecordCollector {
@@ -106,11 +107,15 @@ public class RecordCollectorImpl implements RecordCollector {
log.error("{} Error sending record to topic {}. No more offsets will be recorded for this task and it will be closed as it is a zombie.",logPrefix,topic,exception);
log.error("{} Error sending record (key {} value {} timestamp {}) to topic {} due to {}; "+
"No more records will be sent and no more offsets will be recorded for this task.",
logPrefix,key,value,timestamp,topic,exception);
if(exceptioninstanceofProducerFencedException){
sendException=newProducerFencedException(String.format("%s Abort sending since producer got fenced with a previous record (key %s value %s timestamp %d) to topic %s, error message: %s",
log.error("{} Error sending record to topic {}. No more offsets will be recorded for this task and the exception will eventually be thrown",logPrefix,topic,exception);
sendException=newStreamsException(String.format("%s Abort sending since an error caught with a previous record (key %s value %s timestamp %d) to topic %s due to %s.",
@ -119,21 +124,17 @@ public class RecordCollectorImpl implements RecordCollector {
@@ -119,21 +124,17 @@ public class RecordCollectorImpl implements RecordCollector {
return;
}catch(finalTimeoutExceptione){
if(attempt==MAX_SEND_ATTEMPTS){
thrownewStreamsException(String.format("%s Failed to send record to topic %s after %d attempts",logPrefix,topic,attempt));
thrownewStreamsException(String.format("%s Failed to send record to topic %s due to timeout after %d attempts",logPrefix,topic,attempt));
}
log.warn("{} Timeout exception caught when sending record to topic {} attempt {}",logPrefix,topic,attempt);
log.warn("{} Timeout exception caught when sending record to topic {}; retrying with {} attempt",logPrefix,topic,attempt);