ConsoleProducer currently seems to support writing key messages to a topic. Kafka will use a key hash to propagate the message to sections, at least with default behavior.
Currently, the default separator is \t , so typing key[\t]message will distribute it among the sections:
key1 a-message
You can change the separator by providing the key.separator configuration, for example:
kafka-console-producer --broker-list localhost:9092,localhost:9093 \ --topic mytopic --property key.separator=,
Send such messages:
key2,another-message
I tested this with a standard tab and a custom seperator successfully. Messages were distributed between two separate sections.
source share