title: How to read data using key in Kafka Consumer API?
body: <p>I'm constructing messages using below code...</p>
  
  <pre><code>Producer&lt;String, String&gt; producer = new kafka.javaapi.producer.Producer&lt;String, String&gt;(producerConfig);
  KeyedMessage&lt;String, String&gt; keyedMsg = new KeyedMessage&lt;String, String&gt;(topic, "device-420",  "{message:'hello world'}");          
  producer.send(keyedMsg);
  </code></pre>
  
  <p>And Consuming using following code block...</p>
  
  <pre><code>//Key = topic name, Value = No. of threads for topic
  Map&lt;String, Integer&gt; topicCount = new HashMap&lt;String, Integer&gt;();       
  topicCount.put(topic, 1);
  
  //ConsumerConnector creates the message stream for each topic
  Map&lt;String, List&lt;KafkaStream&lt;byte[], byte[]&gt;&gt;&gt; consumerStreams = consumerConnector.createMessageStreams(topicCount);         
  
  // Get Kafka stream for topic
  List&lt;KafkaStream&lt;byte[], byte[]&gt;&gt; kStreamList = consumerStreams.get(topic);
  
  // Iterate stream using ConsumerIterator
  for (final KafkaStream&lt;byte[], byte[]&gt; kStreams : kStreamList) {
      ConsumerIterator&lt;byte[], byte[]&gt; consumerIte = kStreams.iterator();         
      while (consumerIte.hasNext()) {             
          MessageAndMetadata&lt;byte[], byte[]&gt; msg = consumerIte.next();            
          System.out.println(topic.toUpperCase() + "&gt;"
                  + " Partition:" + msg.partition()
                  + " | Key:"+ new String(msg.key())
                  + " | Offset:" + msg.offset()
                  + " | Message:"+ new String(msg.message()));
      }
  }
  </code></pre>
  
  <p>Everything is working fine because I'm reading data topic wise. So I want to know that Is there any way to to consume data using message <strong>key</strong> i.e. <strong>device-420</strong> in this example?</p>