kafka报org.apache.kafka.common.errors.RecordTooLargeException
生活随笔
收集整理的這篇文章主要介紹了
kafka报org.apache.kafka.common.errors.RecordTooLargeException
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
????kakfa報錯如下:?
java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.RecordTooLargeException: The message is 12792083 bytes when serialized which is larger than the maximum request size you have configured with the max.request.size configuration.? ? 原因是發送的消息過大,大于默認配置。其源碼如下:
ProducerConfig.java
.define(MAX_REQUEST_SIZE_CONFIG,Type.INT,1 * 1024 * 1024,atLeast(0),Importance.MEDIUM,MAX_REQUEST_SIZE_DOC)可以看到默認是1M,只需要在配置kafka連接時,加入配置max.request.size即可,如下:
properties.put("bootstrap.servers", "172.16.40.4:9092"); properties.put("acks", "1"); properties.put("retries", 0); properties.put("batch.size", 16384); properties.put("linger.ms", 1); properties.put("max.request.size", 12695150); properties.put("buffer.memory", 33554432); properties.put("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); properties.put("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");? ? 但是需要注意的是,在這里配置的值應該小于服務端配置的最大值,否則報如下錯誤
org.apache.kafka.common.errors.RecordTooLargeException: The request included a message larger than the max message size the server will accept.? ? 如果要修改服務端配置,則需要修改兩個地方,首先是server.properties,加入
message.max.bytes=12695150? ?然后是producer.properties,加入
max.request.size=12695150???同時,消費端也要配置屬性max.partition.fetch.bytes以接收大數據。
? ?
轉載于:https://my.oschina.net/shyloveliyi/blog/1620012
總結
以上是生活随笔為你收集整理的kafka报org.apache.kafka.common.errors.RecordTooLargeException的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: git push前请先git pull
- 下一篇: java中break标记的使用