Spring integration 卡夫卡没有任何例外

Spring integration 卡夫卡没有任何例外,spring-integration,apache-kafka,kafka-consumer-api,kafka-producer-api,Spring Integration,Apache Kafka,Kafka Consumer Api,Kafka Producer Api,我通过下面提到的Java代码创建了具有多个分区的主题 private void existOrCreateTopicsWithPartition(属性属性属性){ 字符串kafkaServer=prop.getProperty(KafkaProducerKey.BOOTSTRAP_SERVERS_CONFIG.getKey()); int replicationFactor=kafkaServer.split(BROKER\u separation\u REGEX).length; int to

我通过下面提到的Java代码创建了具有多个分区的主题

private void existOrCreateTopicsWithPartition(属性属性属性){
字符串kafkaServer=prop.getProperty(KafkaProducerKey.BOOTSTRAP_SERVERS_CONFIG.getKey());
int replicationFactor=kafkaServer.split(BROKER\u separation\u REGEX).length;
int totalPartionCount;
ZkClient ZkClient=newzkclient(kafkaServer,Integer.MAX_值,Integer.MAX_值,new SerializableSerializer());
ZkUtils ZkUtils=newzkutils(zkClient,newzkconnection(kafkaServer)),false;
字符串producerTopics=prop.getProperty(KafkaProducerKey.PRODUCER_TOPICS.getKey());
字符串topics[]=producerTopics.split(topics\u separator\u REGEX);
for(字符串主题:主题){
topic=topic.trim();
if(!adminiutils.topicExists(zkutils,topic)){
totalPartionCount=Integer.valueOf(prop.getProperty(主题+分区键,“1”));
createTopic(zkutils,topic,totalPartionCount,replicationFactor,newproperties());
}
}
}
java代码成功运行后,我检查了kafka控制台上主题的描述

org@org-VirtualBox:~/Downloads/kafka_2.9.2-0.8.1$ bin/kafka-topics.sh --zookeeper  192.168.56.101:2181 --topic sms_cat_2 --describe
这会给出错误而不是结果

Error while executing topic command next on empty iterator  java.util.NoSuchElementException: next on empty iterator
at scala.collection.Iterator$$anon$3.next(Iterator.scala:27)
at scala.collection.Iterator$$anon$3.next(Iterator.scala:25)
at scala.collection.IterableLike$class.head(IterableLike.scala:90)
at scala.collection.immutable.Map$EmptyMap$.head(Map.scala:88)
at kafka.admin.TopicCommand$$anonfun$describeTopic$1.apply(TopicCommand.scala:147)
at kafka.admin.TopicCommand$$anonfun$describeTopic$1.apply(TopicCommand.scala:137)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:60)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at kafka.admin.TopicCommand$.describeTopic(TopicCommand.scala:137)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:58)
at kafka.admin.TopicCommand.main(TopicCommand.scala)
若我运行在Spring集成帮助下创建的consumer,它会在无限循环中发出警告,如下所示

WARN  NetworkClient:582 - Error while fetching metadata with correlation id 1 : {sms_cat_1=LEADER_NOT_AVAILABLE,  sms_cat_2=INVALID_TOPIC_EXCEPTION}
更新:下面的日志提到命令

bin/kafka-topics.sh --zookeeper 192.168.56.101:2181 --describe

Topic:__consumer_offsets    PartitionCount:50    ReplicationFactor:1    Configs:segment.bytes=104857600,cleanup.policy=compact,compression.type=uncompressed
Topic: __consumer_offsets    Partition: 0    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 1    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 2    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 3    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 4    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 5    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 6    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 7    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 8    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 9    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 10    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 11    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 12    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 13    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 14    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 15    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 16    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 17    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 18    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 19    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 20    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 21    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 22    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 23    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 24    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 25    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 26    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 27    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 28    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 29    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 30    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 31    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 32    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 33    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 34    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 35    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 36    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 37    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 38    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 39    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 40    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 41    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 42    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 43    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 44    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 45    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 46    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 47    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 48    Leader: 0    Replicas: 0    Isr: 0
Topic: __consumer_offsets    Partition: 49    Leader: 0    Replicas: 0    Isr: 0  Error while executing topic command next on empty iterator  java.util.NoSuchElementException: next on empty iterator
at scala.collection.Iterator$$anon$3.next(Iterator.scala:27)
at scala.collection.Iterator$$anon$3.next(Iterator.scala:25)
at scala.collection.IterableLike$class.head(IterableLike.scala:90)
at scala.collection.immutable.Map$EmptyMap$.head(Map.scala:88)
at kafka.admin.TopicCommand$$anonfun$describeTopic$1.apply(TopicCommand.scala:147)
at kafka.admin.TopicCommand$$anonfun$describeTopic$1.apply(TopicCommand.scala:137)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:60)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at kafka.admin.TopicCommand$.describeTopic(TopicCommand.scala:137)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:58)
at kafka.admin.TopicCommand.main(TopicCommand.scala)
有什么建议吗


谢谢

我遇到了同样的问题,我描述了关于卡夫卡的主题,发现其中一个分区是
Leader:-1
我遇到了同样的问题,我描述了关于卡夫卡的主题,发现其中一个分区是
Leader:-1

您可以发布以下命令的结果吗
bin/kafka-topics.sh--zookeer 192.168.56.101:2181--description
?找到更新的问题似乎与kafka问题很接近您可以发布以下命令的结果吗
bin/kafka-topics.sh--zookeer192.168.56.101:2181——描述
?查找更新后的问题似乎与卡夫卡问题很接近