设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 手机 数据
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Kafka之消费与激情(3)

发布时间:2021-05-29 18:39 所属栏目:118 来源:互联网
导读:thrownewIllegalStateException(Consumerisnotsubscribedtoanytopicsorassignedanypartitions); }//pollfornewdatauntilthetimeoutexpires longelapsedTime=0L; do{ client.maybeTriggerWakeup();finallongmetadata

                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  

(编辑:ASP站长网)

网友评论
推荐文章
    热点阅读