跟踪kafka配置max.poll.records参数有否生效
来源:互联网 发布:开通淘宝直播什么要求 编辑:程序博客网 时间:2024/06/05 22:35
kafka消费客户端使用Spring-kafka第三方库的开源jar包,引入Maven
<dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_2.10</artifactId> <version>0.10.2.1</version> </dependency> <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> <version>1.2.1.RELEASE</version> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka-clients</artifactId> <version>0.10.2.1</version> </dependency>
配置kafka参数max.poll.records 为10
断点调试org.springframework.kafka.listener.KafkaMessageListenerContainer里的run()函数里的以下代码
long lastReceive = System.currentTimeMillis();long lastAlertAt = lastReceive;while (isRunning()) {try {if (!this.autoCommit) {processCommits();}processSeeks();if (this.logger.isTraceEnabled()) {this.logger.trace("Polling (paused=" + this.paused + ")...");}ConsumerRecords<K, V> records = this.consumer.poll(this.containerProperties.getPollTimeout()); //拉取数据在这行代码if (records != null && this.logger.isDebugEnabled()) {this.logger.debug("Received: " + records.count() + " records");}if (records != null && records.count() > 0) {if (this.containerProperties.getIdleEventInterval() != null) {lastReceive = System.currentTimeMillis();}// if the container is set to auto-commit, then execute in the// same thread// otherwise send to the buffering queueif (this.autoCommit) {invokeListener(records);}else {if (sendToListener(records)) {if (this.assignedPartitions != null) {// avoid group management rebalance due to a slow// consumerthis.consumer.pause(this.assignedPartitions);this.paused = true;this.unsent = records;}}}}else {if (this.containerProperties.getIdleEventInterval() != null) {long now = System.currentTimeMillis();if (now > lastReceive + this.containerProperties.getIdleEventInterval()&& now > lastAlertAt + this.containerProperties.getIdleEventInterval()) {publishIdleContainerEvent(now - lastReceive);lastAlertAt = now;if (this.theListener instanceof ConsumerSeekAware) {seekPartitions(getAssignedPartitions(), true);}}}}this.unsent = checkPause(this.unsent);}catch (WakeupException e) {this.unsent = checkPause(this.unsent);}catch (Exception e) {if (this.containerProperties.getGenericErrorHandler() != null) {this.containerProperties.getGenericErrorHandler().handle(e, null);}else {this.logger.error("Container exception", e);}}}
注意:kafka在0.9版本无max.poll.records参数,默认拉取记录是500,直到0.10版本才引入该参数,所以在0.9版本配置是无效的。
在ConsumerConfig.java类里有做默认配置拉取默认500
.define(MAX_POLL_RECORDS_CONFIG, Type.INT, 500, atLeast(1), Importance.MEDIUM, MAX_POLL_RECORDS_DOC)
阅读全文
0 0
- 跟踪kafka配置max.poll.records参数有否生效
- Kafka配置参数
- kafka参数配置详解
- kafka参数配置优化
- kafka配置参数
- kafka参数配置
- Kafka配置参数详解
- 推荐: Kafka 配置参数
- kafka所有配置参数说明
- 关于jenkins的poll SCM参数配置
- kafka配置中的坑之: replica.fetch.max.bytes
- trafficserver records.config参数说明
- Kafka 配置参数(非常好的总结)
- Kafka 配置参数汇总及相关说明
- kafka优化–JVM参数配置优化
- Kafka 配置参数(非常好的总结)
- Records
- Records
- NotePad++设置默认编程语言
- CI框架源码阅读笔记6 扩展钩子 Hook.php
- Java——I/O入门相关练习代码
- Timer倒计时
- nbr_table源码之头文件
- 跟踪kafka配置max.poll.records参数有否生效
- git常用命令
- Golang和Erlang的协程调度
- linux卸载mysql,apache,php
- Android——面试题(1)Activity篇
- Fragment事物实现导航页面
- UVA
- php中的数值型字符串相加 相比较(> < ==)
- 你厌恶现在的圈子,那就努力跳出去