title: Running kafka consumer(new Consumer API) forever
body: <p>I have built a queueing system on <code>Apache Kafka</code>. The application will produce messages to particular <code>Kafka topic</code> and at the consumer end I have to consume all the records produced to the topic.<br>
  I wrote consumer using new Java Consumer Api.
  The code looks like  </p>
  
  <pre><code>  Properties props = new Properties();  
                       props.put("bootstrap.servers", kafkaBrokerIp+":9092");  
                       props.put("group.id",groupId);  
                       props.put("enable.auto.commit", "true");
                       props.put("session.timeout.ms", "30000");
                       props.put("auto.offset.reset", "earliest");
          props.put("key.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
          props.put("value.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
          KafkaConsumer&lt;String, String&gt; consumer = new KafkaConsumer(props);
                       consumer.subscribe(Arrays.asList("consumertest"));  
                       while (true) {  
                           ConsumerRecords&lt;String, String&gt; records = consumer.poll(100);  
                           for (ConsumerRecord&lt;String, String&gt; record : records){  
                               System.out.println("Data recieved : "+record.value());  
                               }  
                       }
  </code></pre>
  
  <p>Here I need to run the consumer forever so that any record pushed into kafka topic by the producer should instantly consumed and processed.<br>
  So my Confusion is, is it a right way to use an infinite while loop (like in the sample code) to consume the data ? </p>