These are chat archives for arnaud-lb/php-rdkafka

Oct 2018
Oct 22 2018 14:49

Hi Guys
I want to check if a topic exist before publishing a message.
I tried

$metaData = $producer->getMetadata(true, null, 1000);
$topics = $metaData->getTopics();
It return collection of  RdKafka\Metadata\Topic Object whose topic attribute cannot be accessed

Is there any way to check topic ?

COLE Edouard
Oct 22 2018 16:09
This is working well here
     * @return array
    public function getPartitionsInfo()
        $partitionsInfo = [];

        foreach ($this->kafkaConsumer->getMetadata(true, null, 10000)->getTopics() as $topic)
            $partitionsInfo[$topic->getTopic()] = count($topic->getPartitions());

        return $partitionsInfo;
The kafkaConsumer property is a RdKafka\KafkaConsumer