问题:Java调用kafkaAPI写入数据失败,不报错
[main] INFO org.apache.kafka.common.utils.AppInfoParser - Kafka version : 0.11.0.2 [main] INFO org.apache.kafka.common.utils.AppInfoParser - Kafka commitId : 73be1e1168f91ee2 [main] INFO org.apache.kafka.clients.producer.KafkaProducer - Closing the Kafka producer with timeoutMillis = 9223372036854775807 ms. [kafka-producer-network-thread | producer-1] WARN org.apache.kafka.clients.NetworkClient - Connection to node 0 could not be established. Broker may not be available. [kafka-producer-network-thread | producer-1] WARN org.apache.kafka.clients.NetworkClient - Connection to node 0 could not be established. Broker may not be available. [kafka-producer-network-thread | producer-1] WARN org.apache.kafka.clients.NetworkClient - Connection to node 0 could not be established. Broker may not be available. [kafka-producer-network-thread | producer-1] WARN org.apache.kafka.clients.NetworkClient - Connection to node 0 could not be established. Broker may not be available. [kafka-producer-network-thread | producer-1] WARN org.apache.kafka.clients.NetworkClient - Connection to node 0 could not be established. Broker may not be available. [kafka-producer-network-thread | producer-1] WARN org.apache.kafka.clients.NetworkClient - Connection to node 0 could not be established. Broker may not be available. [kafka-producer-network-thread | producer-1] WARN org.apache.kafka.clients.NetworkClient - Connection to node 0 could not be established. Broker may not be available. [kafka-producer-network-thread | producer-1] WARN org.apache.kafka.clients.NetworkClient - Connection to node 0 could not be established. Broker may not be available.
解决办法
前提:端口开放 9092 2888 3888
修改kafka的配置文件server.properties,按照自己的IP和主机名称修改下面的配置并且打开
感悟:日志的重要性
开始的时候没加日志配置文件和依赖,只知道运行很久才结束,不报错并且插入不成功,很奇怪
后来加入日志,一下就能看出是连接node失败,百度就解决了