title: Spark Streaming + Kafka: how to check name of topic from kafka message
body: <p>I am using Spark Streaming to read from a list of Kafka Topics. 
  I am following the official API at this <a href="http://spark.apache.org/docs/latest/streaming-kafka-0-8-integration.html" rel="nofollow noreferrer">link</a>. The method I am using is:</p>
  
  <pre><code>val kafkaParams = Map("metadata.broker.list" -&gt; configuration.getKafkaBrokersList(), "auto.offset.reset" -&gt; "largest")
  val topics = Set(configuration.getKafkaInputTopic())
  val stream = KafkaUtils.createDirectStream[String, String, StringDecoder, StringDecoder](
              ssc, kafkaParams, topics)
  </code></pre>
  
  <p>I am wondering how will the executor read from the message from the list of topics ? What will be their policy? Will they read a topic and then when they finish the messages pass to the other topics?</p>
  
  <p>And most importantly, how can I, after calling this method, check what is the topic of a message in the RDD? </p>
  
  <pre><code>stream.foreachRDD(rdd =&gt; rdd.map(t =&gt; {
          val key = t._1
          val json = t._2
          val topic = ???
  })
  </code></pre>