I am here asking about closing a kafka consumer. Do I need to close kafka consumer even if the using thread exits? Would not closing it leak resources by any change?
Here is a code example:
public class MyThread extends Thread{
private KafkaConsumer<String, Message> kafkaConsumer;
@Override
public void run() {
kafkaConsumer = initConsumer();
while(true){
kafkaconsumer.poll(1000000)
//Code goes here.
}
}
}
Does the kafkaConsumer
close when MyThread
exits using System.exit
?