I create a new spring boot project with a simple test:
@RunWith(SpringRunner.class)
@SpringBootTest
public class ExampleApplicationTests {
@Test
public void contextLoads() {
}
}
When I run this test it succeeds. But If I add any method annotated @KafkaListener
annotation to any service:
@KafkaListener(topics = "test", groupId = "v-group")
public void test(){
log.info("test");
}
And run test, It works sometimes and throws an exception:
Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata