Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot org.apache.kafka.common.errors.NotLeaderOrpartitionException:此服务器不是该主题分区的负责人-请继续显示_Spring Boot_Apache Kafka_Spring Kafka - Fatal编程技术网

Spring boot org.apache.kafka.common.errors.NotLeaderOrpartitionException:此服务器不是该主题分区的负责人-请继续显示

Spring boot org.apache.kafka.common.errors.NotLeaderOrpartitionException:此服务器不是该主题分区的负责人-请继续显示,spring-boot,apache-kafka,spring-kafka,Spring Boot,Apache Kafka,Spring Kafka,我们正在使用spring、kafka(spring kafka 2.4.5、spring cloud stream 3.0.1)、openshift。我们有以下配置。 多个代理/主题,每个主题有8个分区,复制因子为3,多个spring引导使用者 作为弹性测试的一部分,当我们关闭一个代理时,即使在启动服务器之后,仍然会收到相同的错误,我们得到以下异常 org.apache.kafka.common.errors.NotLeaderForPartitionException: This server

我们正在使用spring、kafka(spring kafka 2.4.5、spring cloud stream 3.0.1)、openshift。我们有以下配置。 多个代理/主题,每个主题有8个分区,复制因子为3,多个spring引导使用者

作为弹性测试的一部分,当我们关闭一个代理时,即使在启动服务器之后,仍然会收到相同的错误,我们得到以下异常

org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition.

2020-05-19 18:39:57.598 ERROR [service,,,] 1 --- [ad | producer-5] o.s.k.support.LoggingProducerListener    : Exception thrown when sending a message with key='{49, 50, 49, 50, 54, 53, 56}' and payload='{123, 34, 115, 111, 117, 114, 99, 101, 34, 58, 34, 72, 67, 80, 77, 34, 44, 34, 110, 97, 109, 101, 34...' to topic topicname
2020-05-19 18:39:57.598  WARN [service,,,] 1 --- [ad | producer-5] o.a.k.clients.producer.internals.Sender  : [Producer clientId=producer-5] Received invalid metadata error in produce request on partition topicname-4 due to org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition.. Going to request metadata update now
我检查了谷歌,大多数人说将重试值更改为大于1会起作用,但由于错误甚至在broker启动后出现,我不确定它是否起作用

这是我在属性文件中的内容:

spring.cloud.stream.kafka.binder.brokers=${output.server}
spring.cloud.stream.kafka.binder.requiredAcks=1
spring.cloud.stream.bindings.outputChannel.destination=${output.topic}
spring.cloud.stream.bindings.outputChannel.content-type=application/json
和一行使用kafka streams API发送消息的代码

`client.outputChannel().send(MessageBuilder.withPayload(message).setHeader(KafkaHeaders.MESSAGE_KEY, message.getId().getBytes()).build());`
请帮帮我

谢谢 Rams

经纪人下跌 关闭其中一个代理时,生产者的元数据更新可能尚未更新。因此,当它尝试为该代理中的分区发送数据时,它将失败,然后请求元数据更新,并再次尝试寻找正确的代理,该代理现在是新的领导者

代理重启 当代理再次添加回集群时,控制器将触发主题分区的重新平衡。所以,还并没有用这个新元数据更新的生产者在试图将数据发送到分区前导已更改的代理时,也会显示失败的操作。在下次重试时更新新元数据后,不应出现这种情况。

Broker down 关闭其中一个代理时,生产者的元数据更新可能尚未更新。因此,当它尝试为该代理中的分区发送数据时,它将失败,然后请求元数据更新,并再次尝试寻找正确的代理,该代理现在是新的领导者

代理重启 当代理再次添加回集群时,控制器将触发主题分区的重新平衡。所以,还并没有用这个新元数据更新的生产者在试图将数据发送到分区前导已更改的代理时,也会显示失败的操作。在下次重试时更新新元数据后,不应发生这种情况