I am trying to run zookeeper using the Java API, so that I am able to start a topic with multiple partitions. I believe this answer does the trick. However, when I try running this code, I get the error:
Unable to connect to zookeeper server 'localhost:2181' with timeout of 8000 ms
On this machine, I don't have a zookeeper server running. But I would like to start an instance in Java (which, I am currently able to do using the ZooKeeperServerMain() class). So perhaps I need to do the same, but combining it somehow with the first answer that contains the possibility of adding multiple partitions to the topic.
For what it's worth, I am able to start zookeeper using this answer, but this will only create one partition for a topic, which is not exactly what I want.
Essentially, I want to start Zookeeper (which I am able to do using the second link), start Kafka locally (which I am also able to do), start a producer, which produces to a single topic but three different partitions, and 3 different consumers, that will read messages, one from each partition (if I understood Kafka correctly, 3 partitions will be divided equally if 3 consumers are started). All this is done using the Java API (I am not running the Kafka scripts or anything). However, I am having difficulty creating a topic with three partitions, which is my question.