sap*_*apy 8 apache-kafka kafka-consumer-api kafka-producer-api spring-kafka
收到以下错误(Kafka 2.1.0):
2018-12-03 21:22:37.873 错误 37645 --- [nio-8080-exec-1] osksupport.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
Run Code Online (Sandbox Code Playgroud)
服务器.属性:
socket.request.max.bytes=104857600
message.max.bytes=41943040
max.request.size=41943040
replica.fetch.max.bytes=41943040
fetch.message.max.bytes=41943040
Run Code Online (Sandbox Code Playgroud)
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");
Run Code Online (Sandbox Code Playgroud)
消费者配置(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");
Run Code Online (Sandbox Code Playgroud)
我还在最后 2 个文件中将字符串更改为数字。多次启动经纪人,并创建新主题。我org.apache.kafka.common.errors.RecordTooLargeException: The request included a message larger than the max message size the server will accept最初遇到错误,通过这些更改得到了修复,但是这个新错误仍然没有运气。
在里面设置一个断点KafkaProducer.ensureValidRecordSize()看看发生了什么。
有了这个应用程序
@SpringBootApplication
public class So53605262Application {
public static void main(String[] args) {
SpringApplication.run(So53605262Application.class, args);
}
@Bean
public NewTopic topic() {
return new NewTopic("so53605262", 1, (short) 1);
}
@Bean
public ApplicationRunner runner(KafkaTemplate<String, String> template) {
return args -> template.send("so53605262", new String(new byte[1024 * 1024 * 2]));
}
}
Run Code Online (Sandbox Code Playgroud)
我得到
该消息在序列化时为 2097240 字节,大于您使用 max.request.size 配置配置的最大请求大小。
正如预期的那样;当我添加
spring.kafka.producer.properties.max.request.size=3000000
Run Code Online (Sandbox Code Playgroud)
(这相当于您的配置,但使用 Spring Boot 属性),我得到
该请求包含的消息大于服务器将接受的最大消息大小。
如果调试没有帮助,也许您可以发布一个完整的小应用程序来展示您所看到的行为。
| 归档时间: |
|
| 查看次数: |
19551 次 |
| 最近记录: |