title: Why kafka consumer code is not returning anything
body: <p>I am new to Kafka. I am using it in Windows 10. I have php 7.4. I have used  <a href="https://github.com/arnaud-lb/php-rdkafka" rel="nofollow noreferrer">arnaud-lb/php-rdkafka</a>  as php kafka client.</p>
  <p>I downloaded Kafka from <a href="https://kafka.apache.org/downloads" rel="nofollow noreferrer">here</a> and kept in c drive. Firstly, I tried producer and consumer on the command line using the following commands</p>
  <pre><code>Terminal 1: start zookeeper server
  .\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
  
  Terminal 2: start kafka
  .\bin\windows\kafka-server-start.bat .\config\server.properties
  
  Terminal 3: Create topic
  .\bin\windows\kafka-topics.bat --create --topic TestTopic --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1
  
  List topics
  .\bin\windows\kafka-topics.bat --list --bootstrap-server localhost:9092
  
  Terminal 4: add data in topics
  .\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic TestTopic
  press enter and now you can enter messages here
  
  Terminal 5: consumer
  .\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic TestTopic --from-beginning
  </code></pre>
  <p>Everything is working fine till here. But my actual requirement is to consume data via PHP code so I can save data in the database. Now I am using command line producer that I discussed above and using the following PHP code for consumer, but it is not returning anything. Even I tried to produce data from <a href="https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/rdkafka.examples-producer.html" rel="nofollow noreferrer">this</a> code, but it is not producing data.</p>
  <pre><code>$conf = new RdKafka\Conf();
  $conf-&gt;set('group.id', 'myConsumerGroup');
  $rk = new RdKafka\Consumer($conf);
  $rk-&gt;addBrokers(&quot;127.0.0.1&quot;);
  $topicConf = new RdKafka\TopicConf();
  $topicConf-&gt;set('auto.commit.interval.ms', 100);
  $topicConf-&gt;set('offset.store.method', 'broker');
  $topicConf-&gt;set('auto.offset.reset', 'earliest');
  $topic = $rk-&gt;newTopic(&quot;TestTopic&quot;, $topicConf);
  $topic-&gt;consumeStart(0, RD_KAFKA_OFFSET_STORED);
  while (true) {
      $message = $topic-&gt;consume(0, 2*10000);
      switch ($message-&gt;err) {
          case RD_KAFKA_RESP_ERR_NO_ERROR:
              var_dump($message);
              break;
          case RD_KAFKA_RESP_ERR__PARTITION_EOF:
              echo &quot;No more messages; will wait for more\n&quot;;
              break;
          case RD_KAFKA_RESP_ERR__TIMED_OUT:
              echo &quot;Timed out\n&quot;;
              break;
          default:
              throw new \Exception($message-&gt;errstr(), $message-&gt;err);
              break;
      }
  }
  </code></pre>
  <p>I am not getting, where is the mistake and what could be its fix?</p>