kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lohith Samaga M <Lohith.Sam...@mphasis.com>
Subject New consumer API waits indefinitely
Date Mon, 04 Apr 2016 05:51:58 GMT
                Good morning.

                I am new to Kafka. So, please bear with me.
                I am using the new Producer and Consumer API with Kafka running on
Windows 7 laptop with zookeeper.

                I was able to send messages using the new Producer API. I can see the messages
in the Kafka data directory.

                However, when I run the consumer, it does not retrieve the messages. It keeps
waiting for the messages indefinitely.
                My code (taken from Javadoc and modified)  is as below:

            props.put("bootstrap.servers", "localhost:9092");
            props.put("group.id", "new01");
            props.put("enable.auto.commit", "true");
            props.put("auto.commit.interval.ms", "1000");
            props.put("session.timeout.ms", "30000");
            props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
            props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");

            KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
            while (true) {
                ConsumerRecords<String, String> records = consumer.poll(100);
                for (ConsumerRecord<String, String> record : records)
                    System.out.printf("offset = %d, key = %s, value = %s", record.offset(),
record.key(), record.value());

                Can anybody please tell me what went wrong?

Thanks & Regards,
M. Lohith Samaga

Information transmitted by this e-mail is proprietary to Mphasis, its associated companies
and/ or its customers and is intended 
for use only by the individual or entity to which it is addressed, and may contain information
that is privileged, confidential or 
exempt from disclosure under applicable law. If you are not the intended recipient or it appears
that this mail has been forwarded 
to you without proper authority, you are notified that any use or dissemination of this information
in any manner is strictly 
prohibited. In such cases, please notify us immediately at mailmaster@mphasis.com and delete
this mail from your records.

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