title: How to use Consumer API of Kafka 0.8.2?
body: <p>I'm getting start with the latest Kafka document <a href="http://kafka.apache.org/documentation.html" rel="noreferrer">http://kafka.apache.org/documentation.html</a>. But I meet some problem when I try to use the new Consumer API. I've done the job with following steps:</p>
  
  <p><strong>1. Add a new dependency</strong></p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;
      &lt;artifactId&gt;kafka-clients&lt;/artifactId&gt;
      &lt;version&gt;0.8.2.1&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>2. Add configurations</strong></p>
  
  <pre><code>    Map&lt;String, Object&gt; config = new HashMap&lt;String, Object&gt;();
      config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,
              "host:9092");
      config.put(ConsumerConfig.GROUP_ID_CONFIG, "test");
      config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
              StringDeserializer.class.getName());
      config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
              StringDeserializer.class.getName());
      config.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY, "range");
  </code></pre>
  
  <p><strong>3. Use KafkaConsumer API</strong></p>
  
  <pre><code>KafkaConsumer&lt;String, String&gt; consumer = new KafkaConsumer&lt;String, String&gt;(config);
  consumer.subscribe("topic");
  </code></pre>
  
  <p>However, when I try to poll message from the broker, I got nothing but null:</p>
  
  <pre><code>Map&lt;String, ConsumerRecords&lt;String, String&gt;&gt; records = consumer.poll(0);
  if (records != null)
      process(records);
  else
      System.err.println("null");
  </code></pre>
  
  <p>And then I know what's wrong with the consumer after I checked the source code:</p>
  
  <pre><code>@Override
  public Map&lt;String, ConsumerRecords&lt;K,V&gt;&gt; poll(long timeout) {
      // TODO Auto-generated method stub
      return null;
  }
  </code></pre>
  
  <p>To make matters worse, I cannot find any other useful information about the 0.8.2 API, since all usages about Kafka are not compatible with the latest version. Could anybody help me? Thanks a lot.</p>