我正在尝试创建一个简单的Kafka客户端,我从Springboot应用程序运行。我的要求是使用Kafka 0.8.2.2版本。应用程序在开始工作正常然后我得到这个异常我无法找到根本原因。
在Kafka日志中,我看到以下异常:
来自分区[TESTQA,2]上的客户端测试组的相关ID为0的偏移请求因代理256上的分区[TESTQA,2]的Leader不是本地的而失败 2017-07-21 03:40:54,186 INFO kafka.network.Processor:关闭套接字连接到/.
kafka.common.NotLeaderForPartitionException: null
at sun.reflect.GeneratedConstructorAccessor41.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
at java.lang.Class.newInstance(Class.java:442) ~[na:1.8.0_131]
at kafka.common.ErrorMapping$.exceptionFor(ErrorMapping.scala:86) ~[kafka_2.10-0.8.2.2.jar:na]
at kafka.consumer.SimpleConsumer.earliestOrLatestOffset(SimpleConsumer.scala:169) ~[kafka_2.10-0.8.2.2.jar:na]
at kafka.consumer.ConsumerFetcherThread.handleOffsetOutOfRange(ConsumerFetcherThread.scala:60) ~[kafka_2.10-0.8.2.2.jar:na]
at kafka.server.AbstractFetcherThread$$anonfun$addPartitions$2.apply(AbstractFetcherThread.scala:177) ~[kafka_2.10-0.8.2.2.jar:na]
at kafka.server.AbstractFetcherThread$$anonfun$addPartitions$2.apply(AbstractFetcherThread.scala:172) ~[kafka_2.10-0.8.2.2.jar:na]
at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:772) ~[scala-library-2.10.4.jar:na]
at scala.collection.immutable.Map$Map2.foreach(Map.scala:130) ~[scala-library-2.10.4.jar:na]
at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:771) ~[scala-library-2.10.4.jar:na]
at kafka.server.AbstractFetcherThread.addPartitions(AbstractFetcherThread.scala:172) ~[kafka_2.10-0.8.2.2.jar:na]
at kafka.server.AbstractFetcherManager$$anonfun$addFetcherForPartitions$2.apply(AbstractFetcherManager.scala:87) ~[kafka_2.10-0.8.2.2.jar:na]
at kafka.server.AbstractFetcherManager$$anonfun$addFetcherForPartitions$2.apply(AbstractFetcherManager.scala:77) ~[kafka_2.10-0.8.2.2.jar:na]
at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:772) ~[scala-library-2.10.4.jar:na]
at scala.collection.immutable.Map$Map2.foreach(Map.scala:130) ~[scala-library-2.10.4.jar:na]
at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:771) ~[scala-library-2.10.4.jar:na]
at kafka.server.AbstractFetcherManager.addFetcherForPartitions(AbstractFetcherManager.scala:77) ~[kafka_2.10-0.8.2.2.jar:na]
at kafka.consumer.ConsumerFetcherManager$LeaderFinderThread.doWork(ConsumerFetcherManager.scala:95) ~[kafka_2.10-0.8.2.2.jar:na]
at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:60) [kafka_2.10-0.8.2.2.jar:na]
答案 0 :(得分:1)
NotLeaderForPartitionException以ERROR级别记录,并具有完整的堆栈跟踪。但实际上,当具有过时元数据的客户端向分区的错误领导者发送请求时,这只是服务器上的信息性消息。