作者:手机用户2502902345 | 来源:互联网 | 2023-10-12 17:54
将单条消息的大小设置为大于服务端可以接受的消息大小,模拟发送异常的场景:消息大小1500message.max.bytes1000batch.size16384日志一直刷:[201
将单条消息的大小设置为大于服务端可以接受的消息大小,模拟发送异常的场景:
消息大小1500
message.max.bytes=1000
batch.size=16384
日志一直刷:
[2019-05-10 16:25:09,233] WARN [Producer clientId=producer-1] Got error produce response in correlation id 61 on topic-partition test-0, splitting and retrying (2147483647 attempts left). Error: MESSAGE_TOO_LARGE (org.apache.kafka.clients.producer.internals.Sender:617)
[2019-05-10 16:25:10,021] WARN [Producer clientId=producer-1] Got error produce response in correlation id 62 on topic-partition test-0, splitting and retrying (2147483647 attempts left). Error: MESSAGE_TOO_LARGE (org.apache.kafka.clients.producer.internals.Sender:617)
[2019-05-10 16:25:10,758] WARN [Producer clientId=producer-1] Got error produce response in correlation id 63 on topic-partition test-0, splitting and retrying (2147483647 attempts left). Error: MESSAGE_TOO_LARGE (org.apache.kafka.clients.producer.internals.Sender:617)
[2019-05-10 16:25:12,071] WARN [Producer clientId=producer-1] Got error produce response in correlation id 64 on topic-partition test-0, splitting and retrying (2147483647 attempts left). Error: MESSAGE_TOO_LARGE (org.apache.kafka.clients.producer.internals.Sender:617)
message.max.bytes 为对端接受消息的最大字节数,batch.size为producer一次发送消息大小。当传递的消息较大时即大于message.max.bytes的值,kafka会根据batch.size的大小对消息进行切分,然而当batch.size>=message.max.bytes 时,消息无法切分,所以会一致报错MESSAGE_TOO_LARGE。这也是kafka的一个bug:https://issues.apache.org/jira/browse/KAFKA-8350
参考链接:https://blog.csdn.net/qq_35440040/article/details/103600861