title: Kafka consumer in Spark Streaming
body: <p>Trying to write a Spark Streaming job that consumes messages from Kafka.  Here’s what I’ve done so far:</p>
  
  <ol>
  <li>Started Zookeeper</li>
  <li>Started Kafka Server</li>
  <li><p>Sent a few messages to the server. I can see them when I run the following:</p>
  
  <pre><code>bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic mytopic --from-beginning
  </code></pre></li>
  <li><p>Now trying to write a program to count # of messages coming in within 5 minutes.</p></li>
  </ol>
  
  <p>The code looks something like this:</p>
  
  <pre><code>Map&lt;String, Integer&gt; map = new HashMap&lt;String, Integer&gt;();
  map.put("mytopic", new Integer(1));
  JavaStreamingContext ssc = new JavaStreamingContext(
          sparkUrl, " Spark Streaming", new Duration(60 * 5 * 1000), sparkHome, new String[]{jarFile});
  JavaPairReceiverInputDStream tweets = KafkaUtils.createStream(ssc, "localhost:2181", "1", map);
  </code></pre>
  
  <p>Not sure what value to use for the 3rd argument (consumer group).  When I run this I get <code>Unable to connect to zookeeper server</code>.  But Zookeeper is running on port <code>2181</code>; otherwise step #3 would not have worked.</p>
  
  <p>Seems like I am not using <code>KafkaUtils.createStream</code> properly.  Any ideas?</p>