Kafka 0.8, is it possible to create topic with partition and replication using java code?

前端 未结 2 1825
野的像风
野的像风 2021-02-04 09:57

In Kafka 0.8beta a topic can be created using a command like below as mentioned here

    bin/kafka-create-topic.sh --zookeeper localhost:2181 --replica 2 --parti         


        
2条回答
  •  迷失自我
    2021-02-04 10:55

    Note: My answer covers Kafka 0.8.1+, i.e. the latest stable version available as of April 2014.

    Yes, you can create a topic programatically via the Kafka API. And yes, you can specify the desired number of partitions as well as the replication factor for the topic.

    Note that the recently released Kafka 0.8.1+ provides a slightly different API than Kafka 0.8.0 (which was used by Biks in his linked reply). I added a code example to create a topic in Kafka 0.8.1+ to my reply to the question How Can we create a topic in Kafka from the IDE using API that Biks was referring to above.

提交回复
热议问题