kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vaibhav Puranik <vpura...@gmail.com>
Subject Getting fixed amount of messages using Zookeeper based consumer
Date Thu, 12 Jul 2012 00:05:11 GMT
Hi all,

Is there any way to get a fixed amount of messages using Zookeeper based
consumer (ConsumerConnector)?

I know that with SimpleConsumer you can pass fetchSize as an argument and
limit the number of messages coming back.

This sample code creates 4 threads that keep consuming forever.

// consume the messages in the threads
for(final KafkaStream<Message> stream: streams) {
  executor.submit(new Runnable() {
    public void run() {
      for(MessageAndMetadata msgAndMetadata: stream) {
        // process message (msgAndMetadata.message())
      }	
    }
  });
}

Regards,
Vaibhav

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