什么是kafka.common.OffsetOutOfRangeException的意思

时间:2014-04-09 08:20:13

标签: apache-kafka

我试图通过Apache Kafka加载数据并不断收到此错误:

  

kafka.common.OffsetOutOfRangeException:偏移量1003786超出范围           at kafka.log.Log $ .findRange(Log.scala:46)           在kafka.log.Log.read(Log.scala:264)           at kafka.server.KafkaRequestHandlers.kafka $ server $ KafkaRequestHandlers $$ readMessageSet(KafkaRequestHandlers.scala:112)           at kafka.server.KafkaRequestHandlers $$ anonfun $ 2.apply(KafkaRequestHandlers.scala:101)           at kafka.server.KafkaRequestHandlers $$ anonfun $ 2.apply(KafkaRequestHandlers.scala:100)           在scala.collection.TraversableLike $$ anonfun $ map $ 1.apply(TraversableLike.scala:206)           在scala.collection.TraversableLike $$ anonfun $ map $ 1.apply(TraversableLike.scala:206)           在scala.collection.IndexedSeqOptimized $ class.foreach(IndexedSeqOptimized.scala:34)           在scala.collection.mutable.ArrayOps.foreach(ArrayOps.scala:34)           在scala.collection.TraversableLike $ class.map(TraversableLike.scala:206)           在scala.collection.mutable.ArrayOps.map(ArrayOps.scala:34)           at kafka.server.KafkaRequestHandlers.handleMultiFetchRequest(KafkaRequestHandlers.scala:100)           at kafka.server.KafkaRequestHandlers $$ anonfun $ handlerFor $ 3.apply(KafkaRequestHandlers.scala:40)           at kafka.server.KafkaRequestHandlers $$ anonfun $ handlerFor $ 3.apply(KafkaRequestHandlers.scala:40)           在kafka.network.Processor.handle(SocketServer.scala:296)           在kafka.network.Processor.read(SocketServer.scala:319)           在kafka.network.Processor.run(SocketServer.scala:214)           在java.lang.Thread.run(Thread.java:724)

这个例外是什么意思以及如何解决它?

1 个答案:

答案 0 :(得分:13)

OffsetOutOfRangeException通常表示客户端已请求服务器上不再提供的范围 根据Kafka设置中的保留策略,主题日志不再存在,可能会发生这种情况 如果您使用SimpleConsumer,则需要在代码中处理OffsetOutOfRange异常。理想情况下,您的消费者应该发出OffsetRequest以获取服务器上当前可用的最新/最早的偏移量,然后在您的FetchRequest中使用它(作为参数)