本文主要是介绍kafka0.8.11版本使用出错,java客户端发送信息主题接收不到,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
错误日志:
Exception in thread "main" kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:90)at kafka.producer.Producer.send(Producer.scala:76)at kafka.javaapi.producer.Producer.send(Producer.scala:33)at com.asiainfo.kafka.kafka_demo4.KafkaProducerTest.main(KafkaProducerTest.java:23)
编写好java的生产者客户端程序,发送数据到指定的topic中,在服务器端打开消费端,可是会报错,并接收不到发送过来的信息。
解决:
这是kafka配置的问题,kafka应该配置好从客户端访问时的ip以及port号 :
配置文件config/server.properties
# The id of the broker. This must be set to a unique integer for each broker.
broker.id=1############################# Socket Server Settings ############################## The port the socket server listens on
port=9092# Hostname the broker will bind to. If not set, the server will bind to all interfaces
#host.name=localhost# Hostname the broker will advertise to producers and consumers. If not set, it uses the
# value for "host.name" if configured. Otherwise, it will use the value returned from
# java.net.InetAddress.getCanonicalHostName().
#advertised.host.name=<hostname routable by clients>
advertised.host.name=192.168.72.18# The port to publish to ZooKeeper for clients to use. If this is not set,
# it will publish the same port that the broker binds to.
#advertised.port=<port accessible by clients>
advertised.port=9092
这里的就是客户端访问kafka时使用的ip
advertised.host.name=192.168.72.18
类似的下面这个就是客户端访问时的端口号:
advertised.port=9092
把上面两个配置添加上,然后客户端访问kafka时使用这个ip和port就可以了
这篇关于kafka0.8.11版本使用出错,java客户端发送信息主题接收不到的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!