title: Unable to get number of messages in kafka topic
body: <p>I am fairly new to kafka. I have created a sample producer and consumer in java. Using the producer, I was able to send data to a kafka topic but I am not able to get the number of records in the topic using the following consumer code.</p>
  
  <pre><code>    public class ConsumerTests {
          public static void main(String[] args) throws Exception {
              BasicConfigurator.configure();
  
              String topicName = "MobileData";
              String groupId = "TestGroup";
              Properties properties = new Properties();
              properties.put("bootstrap.servers", "localhost:9092");
              properties.put("group.id", groupId);
              properties.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
              properties.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
  
              KafkaConsumer&lt;String, String&gt; kafkaConsumer = new KafkaConsumer&lt;&gt;(properties);
              kafkaConsumer.subscribe(Arrays.asList(topicName));
  
  
  try {
    while (true) {
      ConsumerRecords&lt;String, String&gt; consumerRecords = consumer.poll(100);
      System.out.println("Record count is " + records.count());
    }
  } catch (WakeupException e) {
    // ignore for shutdown
  } finally {
    consumer.close();
  }
  
  }
  }
  </code></pre>
  
  <p>I don't get any exception in the console but consumerRecords.count() always returns 0, even if there are messages in the topic. Please let me know, if I am missing something to get the record details.</p>