【发布时间】:2019-05-05 10:14:04
【问题描述】:
出现以下错误(Kafka 2.1.0):
2018-12-03 21:22:37.873 错误 37645 --- [nio-8080-exec-1] o.s.k.support.LoggingProducerListener :抛出异常时 发送 key='null' 和 payload='{82, 73, 70, 70, 36, 96, 19, 0, 87, 65, 86, 69, 102, 109, 116, 32, 16, 0, 0, 0, 1, 0, 1, 0, 68, -84,...' to topic recieved_sound: org.apache.kafka.common.errors.RecordTooLargeException: 序列化时消息为 1269892 字节,大于 您使用 max.request.size 配置的最大请求大小 配置。
我尝试了各种 SO 帖子中的所有建议。
我的 Producer.properties:
max.request.size=41943040
message.max.bytes=41943040
replica.fetch.max.bytes=41943040
fetch.message.max.bytes=41943040
Server.properties:
socket.request.max.bytes=104857600
message.max.bytes=41943040
max.request.size=41943040
replica.fetch.max.bytes=41943040
fetch.message.max.bytes=41943040
ProducerConfig(Spring Boot):
configProps.put("message.max.bytes", "41943040");
configProps.put("max.request.size", "41943040");
configProps.put("replica.fetch.max.bytes", "41943040");
configProps.put("fetch.message.max.bytes", "41943040");
ConsumerConfig (SpringBoot):
props.put("fetch.message.max.bytes", "41943040");
props.put("message.max.bytes", "41943040");
props.put("max.request.size", "41943040");
props.put("replica.fetch.max.bytes", "41943040");
props.put("fetch.message.max.bytes", "41943040");
我还在最后 2 个文件中将字符串更改为数字。多次启动代理,并创建新主题。我最初收到org.apache.kafka.common.errors.RecordTooLargeException: The request included a message larger than the max message size the server will accept 错误,这些更改已修复,但这个新错误仍然没有运气。
【问题讨论】:
-
您的配置看起来不错。我猜也许您没有将更改部署到所有经纪人? Can you check the broker config using bin/kafka-configs.sh 以确保您的配置在所有代理上都正确?
-
另加
max.partition.fetch.bytes -
max.partition.fetch.bytes是一个软限制。来自文档:If the first record batch in the first non-empty partition of the fetch is larger than this limit, the batch will still be returned to ensure that the consumer can make progress. -
您可能需要将 kaka.max.partition.fetch.bytes 而不是 max.partition.fetch.bytes 添加到客户端属性
标签: apache-kafka kafka-consumer-api kafka-producer-api spring-kafka