Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Kafka >> mail # user >> Consumer exception


Copy link to this message
-
Consumer exception
Hi,

I downloaded the latest code from trunk last week and i was trying this
snippet as given in examples.
Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
    topicCountMap.put(topic, new Integer(1));
    Map<String, List<KafkaStream<Message>>> consumerMap consumer.createMessageStreams(topicCountMap);
    KafkaStream<Message> stream =  consumerMap.get(topic).get(0);
    ConsumerIterator<Message> it = stream.iterator();
    while(it.hasNext())
      System.out.println(ExampleUtils.getMessage(it.next().message()));
  }

But its giving following error:
Type mismatch: cannot convert from KafkaStream<MessageAndMetadata> to
KafkaStream<Message> at
ConsumerIterator<Message> it = stream.iterator();

Can you please tell how to run the above snippet with MessageAndMetadata?
And also please tell whether it requires any code changes in producer as
well?

Thanks,
Navneet Sharma
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB