/** * Get producer by broker id * * Method that given a broker id, it will create the producer and * will return it. * * @return IProducer */ protected function getProducerByBrokerId($brokerId) { if (!isset($this->producerList[$brokerId])) { if (!isset($this->brokerMetadata[$brokerId])) { throw new \Kafka\Exception("Broker connection paramters not initialized for broker {$brokerId}"); } $broker = $this->brokerMetadata[$brokerId]; $kafka = new Kafka($broker['host'], $broker['port']); $this->producerList[$brokerId] = $kafka->createProducer(); } return $this->producerList[$brokerId]; }