带有嵌入式Kafka的Spring Kafka测试在删除日志时失败

时间:2019-08-23 08:38:25

标签: apache-kafka spring-kafka spring-kafka-test

我正在使用带有嵌入式kafka的spring kafka进行JUnit测试,在Windows上的每个测试都会给出错误:

Error deleting C:\Users:LXX691\AppData\Local\Temp\kafka-1103610162480947200/.lock: The process cannot access the file because it is being used by another process.

我只是做了如下基本配置

@SpringBootTest(webEnvironment = RANDOM_PORT)
@RunWith(SpringRunner.class)
public class KafkaTest {
  @Autowired
  EmbeddedKafkaBroker broker;

  @Before
  void setUp() throws Exception() {
    // setup producer and consumers
  }

  @Test
  void test() {
    producer.send(new ProducerRecord<>("topic", "content"));
  }
}

任何解决问题的建议或任何变通办法。

1 个答案:

答案 0 :(得分:0)

这是Apache Kafka中的一个已知问题:https://issues.apache.org/jira/browse/KAFKA-8145

不幸的是,在春季卡夫卡峰会上我们无能为力。

在此处查看更多信息:Kafka: unable to start Kafka - process can not access file 00000000000000000000.timeindex和此处https://github.com/spring-projects/spring-kafka/issues/194