我在scala中写了一个kafka使用者进程 -
executor = endpoint.getCamelContext().getExecutorServiceManager().newFixedThreadPool(
this, endpoint.getEndpointUri, concurrentConsumers)
ec = ExecutionContext.fromExecutorService(executor)
val streams = topicMessageStreams.get(endpoint.topicName).asScala
for (stream <- streams) {
Future {
for (messageAndMetaData <- stream) {
val buffer = messageAndMetaData.message.asInstanceOf[Message].payload
val bytes = new Array[Byte](buffer.remaining())
buffer.get(bytes)
var data = new String(bytes)
println(data)
}
}
}
有时它仅消耗部分消息。
我的意思是假设经纪人发送消息为{"a":1,"b":2}
然后它只能使用"b":2}
或"a":1,"b":2}
可能是根本原因?
谢谢,