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.
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.