String consumeTopic = "Tflowmsg_1";
Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
topicCountMap.put(consumeTopic, new Integer(1));
Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = consumer.createMessageStreams(topicCountMap);
KafkaStream<byte[], byte[]> kafkaStream = consumerMap.get(consumeTopic).get(0);
ConsumerIterator<byte[], byte[]> it = kafkaStream.iterator();//此行代码不会执行,停在这里
System.out.println("iterator:"+it);
while (it.hasNext()) {
System.out.println(new String(it.next().message()));
}
最近在学kafka,上面这段代码执行到KafkaStream的iterator()方法时就停住了(好像阻塞了),不会继续往下执行,请教大神可能出错的情况?