1
votes

I am creating a kafka producer and I want to specify partitionId as well while sending the message according to the message type. I have type-partitonId mapping in my Mysql table. In case of new message type I have to create new partition and save that id to Mysql so that it can directly send message to that Id next time same type comes. How can I create new partition for a topic and get the created partitionId ? I am using latest kafka API .9 and Java 1.8.

1

1 Answers

0
votes

Look at the AdminUtils class, specifically at the addPartitions() method. Note that you'll probably have to wait a while for the metadata to be propagated to all of the brokers before actually sending the message.