kafka报org.apache.kafka.common.errors.RecordTooLargeException
生活随笔
收集整理的這篇文章主要介紹了
kafka报org.apache.kafka.common.errors.RecordTooLargeException
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
????kakfa報(bào)錯(cuò)如下:?
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.? ? 原因是發(fā)送的消息過(guò)大,大于默認(rèn)配置。其源碼如下:
ProducerConfig.java
.define(MAX_REQUEST_SIZE_CONFIG,Type.INT,1 * 1024 * 1024,atLeast(0),Importance.MEDIUM,MAX_REQUEST_SIZE_DOC)可以看到默認(rèn)是1M,只需要在配置kafka連接時(shí),加入配置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");? ? 但是需要注意的是,在這里配置的值應(yīng)該小于服務(wù)端配置的最大值,否則報(bào)如下錯(cuò)誤
org.apache.kafka.common.errors.RecordTooLargeException: The request included a message larger than the max message size the server will accept.? ? 如果要修改服務(wù)端配置,則需要修改兩個(gè)地方,首先是server.properties,加入
message.max.bytes=12695150? ?然后是producer.properties,加入
max.request.size=12695150???同時(shí),消費(fèi)端也要配置屬性max.partition.fetch.bytes以接收大數(shù)據(jù)。
? ?
轉(zhuǎn)載于:https://my.oschina.net/shyloveliyi/blog/1620012
總結(jié)
以上是生活随笔為你收集整理的kafka报org.apache.kafka.common.errors.RecordTooLargeException的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: git push前请先git pull
- 下一篇: 零基础Python知识点回顾(一)