现象:生产者不发送消息也不给出错误,服务器上看不到消息积累
from kafka import KafkaConsumer # 生产者 server_list = ["10.15.13.87:9090","10.15.13.88:9090"] producer = KafkaProducer(bootstrap_servers=server_list) msg = "http://www.baidu.com" bmsg = bytes(str(msg).encode('utf-8')) producer.send('topicurl',bmsg)
解决方法:
from kafka import KafkaConsumer # 生产者 server_list = ["10.15.13.87:9090","10.15.13.88:9090"] producer = KafkaProducer(bootstrap_servers=server_list) msg = "http://www.baidu.com" bmsg = bytes(str(msg).encode('utf-8')) producer.send('topicurl',bmsg) #添加下面两行代码即可 producer.flush() producer.close()
先挖坑,原因分析,后续补上
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)