Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Kafka test with embedded Kafka failed on deleting logs

I am using spring kafka with the embedded kafka for JUnit test, it gives an error for every test on 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.

I just did the basic configuration like below

@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"));
  }
}

Any suggestion to resolve or any workaround is appreciated.

like image 564
Jakim Avatar asked Oct 24 '25 05:10

Jakim


1 Answers

This is a known issue in Apache Kafka: https://issues.apache.org/jira/browse/KAFKA-8145.

Unfortunately there is nothing in Spring Kafka we can do on the matter.

See more info here: Kafka: unable to start Kafka - process can not access file 00000000000000000000.timeindex and here https://github.com/spring-projects/spring-kafka/issues/194

like image 88
Artem Bilan Avatar answered Oct 27 '25 05:10

Artem Bilan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!