kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From navneet sharma <navneetsharma0...@gmail.com>
Subject Re: Consumer exception
Date Wed, 06 Jun 2012 03:49:42 GMT
yes of course, the code snippet which i posted is from the
kafka.examples.Consumer
only.

Its not modified to use MessageAndMetadata.

Has it been changed in last week?

Thanks,
Navneet Sharma

On Tue, Jun 5, 2012 at 8:12 PM, Jun Rao <junrao@gmail.com> wrote:

> In trunk, the iterator api has changed to KafkaStream<MessageAndMetadata>.
> Take a look at kafka.examples.Consumer in java-examples.
>
> Thanks,
>
> Jun
>
> On Tue, Jun 5, 2012 at 6:33 AM, navneet sharma
> <navneetsharma0505@gmail.com>wrote:
>
> > 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
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message