저는 자바를 처음 사용하고 블로그를 https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example으로 사용하여 카프카에서 스트림을 수신하기위한 내장형 어댑터를 개발하려고합니다. 이것은 코드의 일부이며 소비자가 단일 스레드라고 가정합니다.카프카 간단한 소비자 - 반복기에 오류가 발생했습니다.
public void run() {
Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
topicCountMap.put(topic, new Integer(getNumThreads()));
Map<String, List<KafkaStream<String, String>>> consumerMap = consumer.createMessageStreams(topicCountMap);
List<KafkaStream<String, String>> streams = consumerMap.get(topic);
executor = Executors.newFixedThreadPool(1);
final KafkaStream<String, String> stream = streams.get(0);
ConsumerIterator<String, String> it = stream.iterator();
while (it.hasNext()) {
// fill the tuple and output the tuple
fillAndOutputTuple();
}
나는 이클립스 IDE에서 it.hasNext()에서이 오류가 발생합니다 : 클래스 파일 반복자는 서명이 포함 '(I) Lscala/수집/Iterator.GroupedIterator;' 57
위치에 잘못 형성된 (가 오류를 제공 그렇게 이상하게도, 위치 57가에 존재하지 않습니다.)
정말
'최종 KafkaStream stream = streams.get (0);'행 뒤에 정확하게 출력되는 내용은 무엇입니까? 디버거를 사용 했습니까? –
user2720864