Problem: When a kafka error is generated in shipping, this error is not being caught by the onfailure method.
Tests executed: First, get a Spring Boot project in version 2.1.8 and set up a call to Kafka as shown below, a KafkaProducexception error will return that will fall into the onfailure. Second, take a Spring Boot project in version 2.5.2 or more current and set up a call to Kafka as shown below, a KafkaException error will return that will not fall into the onfailure.
Exception
Spring Boot 2.1.8 version
org.Springframework.kafka.core.kafkaproducerexception: Failed to Send; in this exception is org.apache.kafka.common.errors.Topicauthoizationexception: Not Authorized to Access Topics: [xxxxxx]
Spring Boot 2.5.2 version
org.Springframework.kafka.kafkaexception: Send Failed; in this exception is org.apache.kafka.common.errors.Topicauthoizationexception: Not Authorized to Access Topics: [xxxxxx]
I believe errors should continue to fall in onFailure.
@Component
public class Send {
private String topic = "XXXXXX";
private final KafkaTemplate<String, String> kafkaTemplate;
public Send(KafkaTemplate<String, String> kafkaTemplate) {
this.kafkaTemplate = kafkaTemplate;
}
public void sendMensagem(String payload) {
Message<String> msg = MessageBuilder.withPayload(payload)
.setHeader(KafkaHeaders.TOPIC, topic)
.build();
ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send(msg);
future.addCallback(new ListenableFutureCallback<>() {
@Override
public void onSuccess(SendResult<String, String> sendResult) {
System.out.println("onSuccess");
}
@Override
public void onFailure(Throwable ex) {
System.out.println("onSuccess");
}
});
}
}
Comment From: wilkinsona
Spring Boot 2.5.2 is no longer supported. Please upgrade to Spring Boot 2.6.x and verify that the problem still occurs. If it does and you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.