You can use the lowlevel consumer for this, it has an API call to retrieve the number of partitions from a topic. 

Easiest way would be to count the depth in:

yourZkPath + "/topics/" + topicName + "/partitions"

Best Regards

On Sat, Jan 3, 2015 at 1:54 PM, Hafiz Mujadid <> wrote:
Hi experts!

I am currently working on spark streaming with kafka. I have couple of
questions related to this task.

1) Is there a way to find number of partitions given a topic name?
2)Is there a way to detect whether kafka server is running or not ?


View this message in context:
Sent from the Apache Spark User List mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail: