kafka消费者发消息失败

报错如下

./kafka-console-producer.sh --broker-list 容器ip:9092 --topic testTopic
>1
[2020-04-01 01:42:01,606] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 1 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:01,698] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 2 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:01,812] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 3 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:01,921] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 4 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:02,029] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 5 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:02,152] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 6 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:02,260] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 7 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:02,374] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 8 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:02,481] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 9 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:02,594] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 10 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:02,704] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 11 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:02,811] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 12 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:02,923] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 13 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2020-04-01 01:42:03,037] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 14 : {testTopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
^Corg.apache.kafka.common.KafkaException: Producer closed while send in progress
    at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:888)
    at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:865)
    at kafka.tools.ConsoleProducer$.send(ConsoleProducer.scala:75)
    at kafka.tools.ConsoleProducer$.main(ConsoleProducer.scala:57)
    at kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)
Caused by: org.apache.kafka.common.KafkaException: Requested metadata update after close
    at org.apache.kafka.clients.producer.internals.ProducerMetadata.awaitUpdate(ProducerMetadata.java:104)
    at org.apache.kafka.clients.producer.KafkaProducer.waitOnMetadata(KafkaProducer.java:1029)
    at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:885)
    ... 4 more
解决办法:

修改server.properties文件

kafka消费者发消息失败_第1张图片

在这两个地方加上容器ip

你可能感兴趣的:(kafka)