Timeout because of missing topic when run spring boot test with @EmbeddedKafka

I'm trying to run an integration test from the following guide https://www.baeldung.com/spring-boot-kafka-testing and I get an error message:

org.springframework.kafka.KafkaException: Send failed

    at org.springframework.kafka.core.KafkaTemplate.doSend(KafkaTemplate.java:815)
    at org.springframework.kafka.core.KafkaTemplate.observeSend(KafkaTemplate.java:773)
    at org.springframework.kafka.core.KafkaTemplate.send(KafkaTemplate.java:551)
    at com.baeldung.kafka.embedded.EmbeddedKafkaIntegrationTest.givenEmbeddedKafkaBroker_whenSendingWithDefaultTemplate_thenMessageReceived(EmbeddedKafkaIntegrationTest.java:48)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
Caused by: org.apache.kafka.common.errors.TimeoutException: Topic testtopic1 not present in metadata after 60000 ms.

The same test was successfully run on my colleague's computer. I've looked at a bunch of questions related to the same error, but none of them helped. Please tell me what else can be checked.

P.S. the full log is here https://github.com/kinderproc/embedded_kafka_test/blob/main/Custom-Errors.txt

UPDATE: I tried to increase the timeout, in case kafka is running out of time. Since an error occurs when sending a message to the queue by the producer, I increased the value of the corresponding parameter in the producer settings, in application.yml.

spring:
  kafka:
    producer:
      properties[max.block.ms]: 300000

Unfortunately, it didn't help. The error is still the same.

enter image description here

What's interesting is the name of the topic in the error message is "topic1", but I expect to see "embedded-test-topic" from application.yml. It seems that the topic name is not taken from application.yml, but from application.properties.

Upvotes: 0

Views: 51

Answers (0)

Related Questions