我的Kafka版本是:0.10.0.1
当我使用org.apache.kafka.clients.consumer.KafkaConsumer#poll
方法轮询记录时,它取得的记录少于我的max.poll.records
值。
我正在寻找一些配置设置,使用它可以增加单个轮询中轮询的记录的数量。
我尝试增加kafka消费者的max.poll.interval.ms
属性,但它没有帮助。
消费者配置:
metric.reporters = []
metadata.max.age.ms = 300000
partition.assignment.strategy = [org.apache.kafka.clients.consumer.RangeAssignor]
reconnect.backoff.ms = 50
sasl.kerberos.ticket.renew.window.factor = 0.8
max.partition.fetch.bytes = 1048576
bootstrap.servers = [broker1:9092, broker2:9092]
ssl.keystore.type = JKS
enable.auto.commit = true
sasl.mechanism = GSSAPI
interceptor.classes = null
exclude.internal.topics = true
ssl.truststore.password = null
client.id =
ssl.endpoint.identification.algorithm = null
max.poll.records = 5000
check.crcs = true
request.timeout.ms = 600500
heartbeat.interval.ms = 3000
auto.commit.interval.ms = 5000
receive.buffer.bytes = 65536
ssl.truststore.type = JKS
ssl.truststore.location = null
ssl.keystore.password = null
fetch.min.bytes = 30000000
send.buffer.bytes = 131072
value.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
group.id = G1
retry.backoff.ms = 100
sasl.kerberos.kinit.cmd = /usr/bin/kinit
sasl.kerberos.service.name = null
sasl.kerberos.ticket.renew.jitter = 0.05
ssl.trustmanager.algorithm = PKIX
ssl.key.password = null
fetch.max.wait.ms = 500
sasl.kerberos.min.time.before.relogin = 60000
connections.max.idle.ms = 540000
session.timeout.ms = 60000
metrics.num.samples = 2
key.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
ssl.protocol = TLS
ssl.provider = null
ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
ssl.keystore.location = null
ssl.cipher.suites = null
security.protocol = PLAINTEXT
ssl.keymanager.algorithm = SunX509
metrics.sample.window.ms = 30000
auto.offset.reset = earliest
答案 0 :(得分:0)
我相信您需要将当前配置中的fetch.max.wait.ms增加为默认值500.
fetch.max.wait.ms:服务器阻止的最长时间 如果没有足够的数据,在回答获取请求之前 立即满足fetch.min.bytes给出的要求。
答案 1 :(得分:0)
更改max.partition.fetch.bytes
将解决问题。
例如,使用以下设置,每个poll
将返回123456条记录:
props.put("max.poll.records", "123456");
props.put("max.partition.fetch.bytes","100000000");