tarun nt
tarun nt

Reputation: 33

Kafka resource leaks

Note: after creating a KafkaProducer you must always close() it to avoid resource leaks.

went through the documentation but could not understand it. Can anyone explain what it really means.

Upvotes: 0

Views: 148

Answers (1)

andreoss
andreoss

Reputation: 1800

It means that you have to use try-with-resource on it, or close it explicitly when you are done using this producer. Producer implements Closable and does many cleanup routines when #close() method is being called, such as stopping threads and closing i/o streams. Same goes for Consumer.

Resource leaks in general may cause performance issues, such prevent proper work of GC, exhaust available limits of file handlers, cause network slowdown and so on.

Upvotes: 1

Related Questions