title: Kafka: what's the best way to dynamically determine the number of partitions in a topic from the consumer side?
body: <p>We have Java code that manages a thread pool of Kafka stream consumers reading a four partitions topic (therefore we have four consumer threads).</p>
  
  <p><em>What's the recommended way to retrieve the number of partitions dynamically, so that the initialization code in the thread pool cat set up the right number of threads?</em></p>
  
  <p>Being able dynamically adjust to an increasing number of partitions is not a requirement.</p>
  
  <p>Looking at the Java API (v.0.8.1) I couldn't find a straightforward way to do it. Currently I'm browsing the Scala source code and I see promising classes (Scala solutions to this problem are welcome as well), however I also wanted to ask the community about this in case somebody already found a nice way to do it.</p>
  
  <p>Thanks,</p>