问题
Does anybody know if
kafka.javaapi.producer.Producer
can be reused among several method invocations (e.g. several send(...)) or it should be closed each time?
回答1:
Yes, it can surely be reused. Producer creation is pretty slow operation because it requires establishing connection to all partitions (and probably zookeeper). So, Producers should be reused when possible.
来源:https://stackoverflow.com/questions/14070008/apache-kafka-java-producer-reusability