title: Kafka scala Consumer code - to print consumed records
body: <p>As i am creating simple kafka consumer as below by using url :<a href="https://gist.github.com/akhil/6dfda8a04e33eff91a20" rel="nofollow noreferrer">https://gist.github.com/akhil/6dfda8a04e33eff91a20</a> .</p>
  
  <p>In that link, to print the consumed record, used a word "asScala" , that is not identified. and kindly , tell me, how to iterate the return type : ConsumerRecord[String,String] , which is poll() method's return type.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import java.util
  import java.util.Properties
  
  import org.apache.kafka.clients.consumer.{ConsumerRecords, KafkaConsumer}
  
   
  object KafkaConsumerEx extends App {
  
    val topic_name = "newtopic55"
    val consumer_group = "KafkaConsumerBatch"
  
    val prot = new Properties()
    prot.put("bootstrap.servers","localhost:9092")
    prot.put("group.id",consumer_group)
    prot.put("key.deserializer",  "org.apache.kafka.common.serialization.StringDeserializer")
    prot.put("value.deserializer","org.apache.kafka.common.serialization.StringDeserializer")
  
    val kfk_consumer = new KafkaConsumer[String,String](prot)
    kfk_consumer.subscribe(util.Collections.singleton(topic_name))
    println("here")
  
     while(true){
      val consumer_record : ConsumerRecords[String, String]  = kfk_consumer.poll(100)
      println("records count : " + consumer_record.count())
      println("records partitions: " + consumer_record.partitions())
      consumer_record.iterator().
  
  
    }
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks in adv.</p>