Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish KafkaTemplate #3065

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -839,17 +839,17 @@ private Callback buildCallback(final ProducerRecord<K, V> producerRecord, final
}
}
catch (Exception e) {
KafkaTemplate.this.logger.warn(e, () -> "Error executing interceptor onAcknowledgement callback");
this.logger.warn(e, () -> "Error executing interceptor onAcknowledgement callback");
}
try {
if (exception == null) {
successTimer(sample, producerRecord);
observation.stop();
future.complete(new SendResult<>(producerRecord, metadata));
if (KafkaTemplate.this.producerListener != null) {
KafkaTemplate.this.producerListener.onSuccess(producerRecord, metadata);
if (this.producerListener != null) {
this.producerListener.onSuccess(producerRecord, metadata);
}
KafkaTemplate.this.logger.trace(() -> "Sent ok: " + KafkaUtils.format(producerRecord)
this.logger.trace(() -> "Sent ok: " + KafkaUtils.format(producerRecord)
+ ", metadata: " + metadata);
}
else {
Expand All @@ -858,17 +858,14 @@ private Callback buildCallback(final ProducerRecord<K, V> producerRecord, final
observation.stop();
future.completeExceptionally(
new KafkaProducerException(producerRecord, "Failed to send", exception));
if (KafkaTemplate.this.producerListener != null) {
KafkaTemplate.this.producerListener.onError(producerRecord, metadata, exception);
if (this.producerListener != null) {
this.producerListener.onError(producerRecord, metadata, exception);
}
KafkaTemplate.this.logger.debug(exception, () -> "Failed to send: "
+ KafkaUtils.format(producerRecord));
this.logger.debug(exception, () -> "Failed to send: " + KafkaUtils.format(producerRecord));
}
}
finally {
if (!KafkaTemplate.this.transactional) {
closeProducer(producer, false);
}
closeProducer(producer, this.transactional);
}
};
}
Expand Down Expand Up @@ -985,7 +982,6 @@ public void destroy() {
}
}

@SuppressWarnings("serial")
private static final class SkipAbortException extends RuntimeException {

SkipAbortException(Throwable cause) {
Expand Down