加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_宿迁站长网 (https://www.0527zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Kafka之消费与激情

发布时间:2021-05-30 10:17:03 所属栏目:Linux 来源:互联网
导读:副标题#e# 首先,我们来看看消费。Kafka提供了非常简单的消费API,使用者只需初始化Kafka的Broker Server地址,然后实例化KafkaConsumer类即可拿到Topic中的数据。一个简单的Kafka消费实例代码如下所示: publicclassJConsumerSubscribeextendsThread{ publ

        // We do not want to be stuck blocking in poll if we are missing some positions  

        // since the offset lookup may be backing off after a failure  

        // NOTE: the use of cachedSubscriptionHashAllFetchPositions means we MUST call  

        // updateAssignmentMetadataIfNeeded before this method.  

        if (!cachedSubscriptionHashAllFetchPositions && pollTimeout > retryBackoffMs) {  

            pollTimeout = retryBackoffMs;  

        }  

        client.poll(pollTimeout, startMs, () -> {  

            // since a fetch might be completed by the background thread, we need this poll condition  

            // to ensure that we do not block unnecessarily in poll()  

            return !fetcher.hasCompletedFetches();  

        });  

(编辑:云计算网_宿迁站长网)

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