use of com.jeesuite.kafka.serializer.MessageDecoder in project jeesuite-libs by vakinge.
the class OldApiTopicConsumer method start.
@Override
public void start() {
// 重置offset
if (consumerContext.getOffsetLogHanlder() != null) {
resetCorrectOffsets();
}
Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
for (String topicName : consumerContext.getMessageHandlers().keySet()) {
int nThreads = 1;
topicCountMap.put(topicName, nThreads);
logger.info("topic[{}] assign fetch Threads {}", topicName, nThreads);
}
StringDecoder keyDecoder = new StringDecoder(new VerifiableProperties());
MessageDecoder valueDecoder = new MessageDecoder(deserializer);
Map<String, List<KafkaStream<String, Object>>> consumerMap = this.connector.createMessageStreams(topicCountMap, keyDecoder, valueDecoder);
for (String topicName : consumerContext.getMessageHandlers().keySet()) {
final List<KafkaStream<String, Object>> streams = consumerMap.get(topicName);
for (final KafkaStream<String, Object> stream : streams) {
MessageProcessor processer = new MessageProcessor(topicName, stream);
this.fetchExecutor.execute(processer);
}
}
//
runing.set(true);
}
Aggregations