I am using kafka-clients library for integrating Kafka with a Scala application. And finding it difficult to understand, how and when TCP connections are made between Brokers and Producers/Consumers.
Please verify my understanding on the below points-
(1) No TCP connection is established on initialisation of KafkaProducer instance.
val producer = new KafkaProducer[String, String](properties)
This also holds true for KafkaConsumer.
val consumer = new KafkaConsumer[String, String](properties)
(2) First TCP connection (between Broker and Producer) is established on producing a record to Broker.
producer.send(record1)
(3) Subsequent send()
calls from the same Producer to same Broker will share same TCP connection irrespective of the Topic.
producer.send(record2)
(4) In case of Consumer, first TCP connection is established on polling a Topic (not on Subscription).
val records = consumer.poll(timeout)
(5) Subsequent calls to poll by the same Consumer to the same Broker share the same connection.