@@ -200,21 +200,20 @@ void ClientImpl::createProducerAsync(const std::string& topic, const ProducerCon
200200
201201 if (autoDownloadSchema) {
202202 auto self = shared_from_this ();
203- auto lookup = getLookup ();
204- lookup->getSchema (topicName).addListener (
203+ getSchema (topicName).addListener (
205204 [self, topicName, callback](Result res, const SchemaInfo& topicSchema) {
206205 if (res != ResultOk) {
207206 callback (res, Producer ());
208207 return ;
209208 }
210209 ProducerConfiguration conf;
211210 conf.setSchema (topicSchema);
212- self->getLookup ()-> getPartitionMetadataAsync (topicName).addListener (
211+ self->getPartitionMetadataAsync (topicName).addListener (
213212 std::bind (&ClientImpl::handleCreateProducer, self, std::placeholders::_1,
214213 std::placeholders::_2, topicName, conf, callback));
215214 });
216215 } else {
217- getLookup ()-> getPartitionMetadataAsync (topicName).addListener (
216+ getPartitionMetadataAsync (topicName).addListener (
218217 std::bind (&ClientImpl::handleCreateProducer, shared_from_this (), std::placeholders::_1,
219218 std::placeholders::_2, topicName, conf, callback));
220219 }
@@ -287,7 +286,7 @@ void ClientImpl::createReaderAsync(const std::string& topic, const MessageId& st
287286 }
288287
289288 MessageId msgId (startMessageId);
290- getLookup ()-> getPartitionMetadataAsync (topicName).addListener (
289+ getPartitionMetadataAsync (topicName).addListener (
291290 std::bind (&ClientImpl::handleReaderMetadataLookup, shared_from_this (), std::placeholders::_1,
292291 std::placeholders::_2, topicName, msgId, conf, callback));
293292}
@@ -400,8 +399,7 @@ void ClientImpl::subscribeWithRegexAsync(const std::string& regexPattern, const
400399 return ;
401400 }
402401
403- getLookup ()
404- ->getTopicsOfNamespaceAsync (topicNamePtr->getNamespaceName (), mode)
402+ getTopicsOfNamespaceAsync (topicNamePtr->getNamespaceName (), mode)
405403 .addListener (std::bind (&ClientImpl::createPatternMultiTopicsConsumer, shared_from_this (),
406404 std::placeholders::_1, std::placeholders::_2, regexPattern, mode,
407405 subscriptionName, conf, callback));
@@ -423,9 +421,8 @@ void ClientImpl::createPatternMultiTopicsConsumer(Result result, const Namespace
423421
424422 auto interceptors = std::make_shared<ConsumerInterceptors>(conf.getInterceptors ());
425423
426- consumer = std::make_shared<PatternMultiTopicsConsumerImpl>(shared_from_this (), regexPattern, mode,
427- *matchTopics, subscriptionName, conf,
428- getLookup (), interceptors);
424+ consumer = std::make_shared<PatternMultiTopicsConsumerImpl>(
425+ shared_from_this (), regexPattern, mode, *matchTopics, subscriptionName, conf, interceptors);
429426
430427 consumer->getConsumerCreatedFuture ().addListener (
431428 std::bind (&ClientImpl::handleConsumerCreated, shared_from_this (), std::placeholders::_1,
@@ -472,7 +469,7 @@ void ClientImpl::subscribeAsync(const std::vector<std::string>& originalTopics,
472469 auto interceptors = std::make_shared<ConsumerInterceptors>(conf.getInterceptors ());
473470
474471 ConsumerImplBasePtr consumer = std::make_shared<MultiTopicsConsumerImpl>(
475- shared_from_this (), topics, subscriptionName, topicNamePtr, conf, getLookup (), interceptors);
472+ shared_from_this (), topics, subscriptionName, topicNamePtr, conf, interceptors);
476473
477474 consumer->getConsumerCreatedFuture ().addListener (std::bind (&ClientImpl::handleConsumerCreated,
478475 shared_from_this (), std::placeholders::_1,
@@ -502,7 +499,7 @@ void ClientImpl::subscribeAsync(const std::string& topic, const std::string& sub
502499 }
503500 }
504501
505- getLookup ()-> getPartitionMetadataAsync (topicName).addListener (
502+ getPartitionMetadataAsync (topicName).addListener (
506503 std::bind (&ClientImpl::handleSubscribe, shared_from_this (), std::placeholders::_1,
507504 std::placeholders::_2, topicName, subscriptionName, conf, callback));
508505}
@@ -525,9 +522,9 @@ void ClientImpl::handleSubscribe(Result result, const LookupDataResultPtr& parti
525522 callback (ResultInvalidConfiguration, Consumer ());
526523 return ;
527524 }
528- consumer = std::make_shared<MultiTopicsConsumerImpl>(
529- shared_from_this (), topicName, partitionMetadata->getPartitions (), subscriptionName, conf ,
530- getLookup () , interceptors);
525+ consumer = std::make_shared<MultiTopicsConsumerImpl>(shared_from_this (), topicName,
526+ partitionMetadata->getPartitions (),
527+ subscriptionName, conf , interceptors);
531528 } else {
532529 auto consumerImpl = std::make_shared<ConsumerImpl>(shared_from_this (), topicName->toString (),
533530 subscriptionName, conf,
@@ -680,9 +677,9 @@ void ClientImpl::getPartitionsForTopicAsync(const std::string& topic, const GetP
680677 return ;
681678 }
682679 }
683- getLookup ()-> getPartitionMetadataAsync (topicName).addListener (
684- std::bind (&ClientImpl::handleGetPartitions, shared_from_this (), std::placeholders::_1,
685- std::placeholders::_2, topicName, callback));
680+ getPartitionMetadataAsync (topicName).addListener (std::bind (&ClientImpl::handleGetPartitions,
681+ shared_from_this (), std::placeholders::_1,
682+ std::placeholders::_2, topicName, callback));
686683}
687684
688685void ClientImpl::closeAsync (const CloseCallback& callback) {
@@ -802,7 +799,9 @@ void ClientImpl::shutdown() {
802799 << " consumers have been shutdown." );
803800 }
804801
805- getLookup ()->close ();
802+ std::shared_lock lock (mutex_);
803+ lookupServicePtr_->close ();
804+ lock.unlock ();
806805 if (!pool_.close ()) {
807806 // pool_ has already been closed. It means shutdown() has been called before.
808807 return ;
0 commit comments