For #1, fetcher.getTopicMetadata() is called. If you have time, you can read getTopicMetadata(). It is a blocking call with given timeout.
For #2, I don't see any mechanism for metadata sharing. FYI On Fri, Dec 29, 2017 at 8:25 AM, Viliam Ďurina <viliam.dur...@gmail.com> wrote: > Hi, > > I use KafkaConsumer.partitionsFor() method to discover partitions that > might be added at runtime. I use manual partition assignment. I call it > once per second and rely on the metadata.max.age.ms property to throttle > real number of remote calls. > > My questions: > > 1. > > can the partitionsFor call block after we have initial metadata? I mean, > when the metadata are expired, will it return latest metadata > immediately > and start fetching new metadata on the background or will it block. > 2. > > when I have multiple consumers for the same topic (one for each > consuming thread), do they share metadata or each of them does a > separate > request. > > Thanks, > Viliam > >