是否有可能在kafka客户端java 0.8.0版本中设置消耗的偏移量?

时间:2017-07-21 06:53:32

标签: apache-kafka kafka-consumer-api

我们可以在Kafka java client-0.8.0版本中设置消费偏移量(抱歉已过时)。我在最新版本中发现了这个,但我希望它在0.8.0版本中

到目前为止的代码:

Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
topicCountMap.put(topic, new Integer(1));
Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = consumer.createMessageStreams(topicCountMap);
KafkaStream<byte[], byte[]> stream = consumerMap.get(topic).get(0);
ConsumerIterator<byte[], byte[]> it = stream.iterator();
while(it.hasNext()){ 
    String consumerMessage = new String(it.next().message());
}

0 个答案:

没有答案