title: Kafka Consumer to read from multiple topics
body: <p>I am very new to Kafka. I am creating two topics and publishing on these two topics from two Producers. I have one consumer which consumes the messages from both the topics. This is because I want to process according to the priority. </p>
  
  <p>I am getting a stream from both the topics but as soon as I start iterating on <code>ConsumerItreator</code> of any stream, it blocks there. As it's written in documentation, it will be blocked till it gets a new message.</p>
  
  <p>Is any one aware of how to read from two topics and two streams from a single Kafka Consumer?</p>
  
  <pre class="lang-java prettyprint-override"><code>    Map&lt;String, Integer&gt; topicCountMap = new HashMap&lt;String, Integer&gt;();
                  topicCountMap.put(KafkaConstants.HIGH_TEST_TOPIC, new Integer(1));
                  topicCountMap.put(KafkaConstants.LOW_TEST_TOPIC, new Integer(1));
                  Map&lt;String, List&lt;KafkaStream&lt;byte[], byte[]&gt;&gt;&gt; consumerMap = consumerConnector.createMessageStreams(topicCountMap);
                  KafkaStream&lt;byte[], byte[]&gt; highPriorityStream = consumerMap.get(KafkaConstants.HIGH_TEST_TOPIC).get(0);
                  ConsumerIterator&lt;byte[], byte[]&gt; highPrioerityIterator = highPriorityStream.iterator();
  
                  while (highPriorityStream.nonEmpty() &amp;&amp; highPrioerityIterator.hasNext())
                  {
                      byte[] bytes = highPrioerityIterator.next().message();
                      Object obj = null;
                      CLoudDataObject thunderDataObject = null;
                      try
                      {
  
                          obj = SerializationUtils.deserialize(bytes);
                          if (obj instanceof CLoudDataObject)
                          {
                              thunderDataObject = (CLoudDataObject) obj;
                              System.out.println(thunderDataObject);
                              // TODO Got the Thunder object here, now write code to send it to Thunder service.
                          }
  
                      }
                      catch (Exception e)
                      {
                      }
                  }
  </code></pre>