[ https://issues.apache.org/jira/browse/KAFKA-2275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14627186#comment-14627186 ]
Onur Karaman commented on KAFKA-2275: ------------------------------------- Currently, the consumer has the following API: public List<PartitionInfo> partitionsFor(String topic); As an alternative to creating a listTopics API, we can just replace the existing partitionsFor with: public Future<Map<String, List<PartitionInfo>>> partitionsFor(String... topics); The map's key is the topic and the values are the PartitionInfos for that topic. Passing in no topics would get all the PartitionInfo for all topics. The listTopics API anyway needs to issue an empty metadata request which returns everything so a two-step approach seems redundant. Having the same API in the producer may help address the concerns in KAFKA-1835. We considered other alternatives like ripping out partitionsFor from both KafkaConsumer and KafkaProducer into its own admin client. That admin client would only contain orchestration or cluster state APIs, but this wasn't really fleshed out and the above solution returning the Future Map seems to work for now. > Add a ListTopics() API to the new consumer > ------------------------------------------ > > Key: KAFKA-2275 > URL: https://issues.apache.org/jira/browse/KAFKA-2275 > Project: Kafka > Issue Type: Sub-task > Components: consumer > Reporter: Guozhang Wang > Assignee: Ashish K Singh > Priority: Critical > Fix For: 0.8.3 > > > With regex subscription like > {code} > consumer.subscribe("topic*") > {code} > The partition assignment is automatically done at the Kafka side, while there > are some use cases where consumers want regex subscriptions but not > Kafka-side partition assignment, rather with their own specific partition > assignment. With ListTopics() they can periodically check for topic list > changes and specifically subscribe to the partitions of the new topics. > For implementation, it involves sending a TopicMetadataRequest to a random > broker and parse the response. -- This message was sent by Atlassian JIRA (v6.3.4#6332)