Hey Siyuan, Are you also consuming from the topics you are querying with partitionsFor? I'm guessing the problem is that we're pulling the metadata from a local cache, and it's not refreshed as quick as you're expecting (the default is 5 minutes). We only use the cache for topics which have partitions assigned. My personal feeling is that we should probably avoid using the cache entirely for this API. Anyway, I can think of two ways to mitigate the problem at the moment.
1. (Preferred) Reduce metadata.max.age.ms in the consumer config to ensure that metadata refreshes occur more frequently. 2. Use a separate instance of KafkaConsumer which has no assignment to query metadata. -Jason On Mon, Nov 30, 2015 at 8:51 AM, hsy...@gmail.com <hsy...@gmail.com> wrote: > Hi guys, > > I want to use partitionsFor method of new consumer API periodically to get > the monitor partition metadata change, It seems it only issue remote call > to the server for the first time. If I add partitions after that, > partitionsFor will return stale value. Is there a way to reuse consumer > object to refresh the metadata change. Thanks! > > regards, > Siyuan >