Kafka Consumer's poll() method gets blocked
Reason might be the machine where your consumer code is running is unable to connect to zookeeper. Try running the same consumer code on the machine where your Kafka is installed (i tried this and worked for me). I also solved problem by mentioning the below properties in server.properties file:
advertised.host.name="ip address which you want to expose"
// in my case it is public ip of ec2 machine, i have kafka and zookeeper installed on same ec2.
advertised.port=9092
ConsumerRecords<String, String> records = consumer.poll(100);
The above statement doesn't mean consumer will time out after 100 ms, it is the polling period. Whatever data it captures in 100 ms is read into records collection.