加入收藏 | 设为首页 | 会员中心 | 我要投稿 衡阳站长网 (https://www.0734zz.cn/)- 数据集成、设备管理、备份、数据加密、智能搜索!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Kafka之消费与激情

发布时间:2021-05-30 01:09:25 所属栏目:Linux 来源:互联网
导读:1、Kafka消费 首先,我们来看看消费。Kafka提供了非常简单的消费API,使用者只需初始化Kafka的Broker Server地址,然后实例化KafkaConsumer类即可拿到Topic中的

                throw new IllegalStateException("Consumer is not subscribed to any topics or assigned any partitions");  

            }            // poll for new data until the timeout expires  

            long elapsedTime = 0L;  

            do {  

                client.maybeTriggerWakeup();                final long metadataEnd;                if (includeMetadataInTimeout) {  

                    final long metadataStart = time.milliseconds();                    if (!updateAssignmentMetadataIfNeeded(remainingTimeAtLeastZero(timeoutMs, elapsedTime))) {  

                        return ConsumerRecords.empty();  

                    }                    metadataEnd = time.milliseconds();                    elapsedTime += metadataEnd - metadataStart;                } else {  

                    while (!updateAssignmentMetadataIfNeeded(Long.MAX_VALUE)) {  

                        log.warn("Still waiting for metadata");  

                    }                    metadataEnd = time.milliseconds();                }                final Map<TopicPartition, List<ConsumerRecord<K, V>>> records = pollForFetches(remainingTimeAtLeastZero(timeoutMs, elapsedTime));                if (!records.isEmpty()) {  

                    // before returning the fetched records, we can send off the next round of fetches  

(编辑:衡阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读