Kafka Consumer没有消费完整的消息

时间:2014-05-02 11:52:39

标签: scala apache-kafka

我在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}

可能是根本原因?

谢谢,

0 个答案:

没有答案