kafka发送的字符串长度问题

我在客户端模拟发送一个特别长的字符串,客户端会漏掉一部分。请问这种情况怎么解决,谢谢。

发送的消息如下

{"header":{"msgId":10,"lineId":6},"msgBody":{"a":2,"b":[{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6}]}}







发表于: 3月前   最后更新时间: 3月前   游览量:575
上一条: 到头了!
下一条: 已经是最后了!

评论…


  • 这个不会吧。你把你要发的消息贴出来 我模拟一下。
    • 我是发送的完整的对象,但是往producer发的时候 总会发送不完整 会丢失部分数据。{"header":{"msgId":10,"lineId":6},"msgBody":{"a":2,"b":[{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6},{"c":6,"d":6,"e":6,"f":6,"g":"a","h":"a","i":"a","j":6,"k":"a","l":"a","m":6,"n":6,"o":6}]}}

        • 我测试过了,消息没丢。
          步骤:
          1、先把要发送的消息写到test.txt中。
          2、执行发送 bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test < test.txt 
          消费者正常拿到全部消息。
          • 评论…
            • in this conversation