在Kstreams中如何根据消息中的特定键以分区方式写入kafka

In Kstreams how to write to kafka in partitioned way based on a particular key in message

在 kstreams 高级 DSL 中,我们有 to 方法,如果说我们想根据输出消息中的键以分区方式将输出写入 kafka,有没有办法。

输出记录默认按键分区。此外,您可以通过重载 to() 方法来提供自己的分区程序:

void to(StreamPartitioner<? super K,? super V> partitioner,
  String topic)

http://kafka.apache.org/0110/javadoc/org/apache/kafka/streams/kstream/KStream.html#to(org.apache.kafka.streams.processor.StreamPartitioner,%20java.lang.String)