有没有办法将数据发送到主题的特定分区

Is there any way to send a data to particular partition of topic

如何将kstream中的数据发送到特定主题分区?

比如topicA分区2

我试过了mysteam.to("topic"); 但是没有用

您可以使用 Produced 将您自己的分区程序传递到 KStream.to()

https://kafka.apache.org/23/javadoc/org/apache/kafka/streams/kstream/KStream.html#to-java.lang.String-org.apache.kafka.streams.kstream.Produced-

https://kafka.apache.org/23/javadoc/org/apache/kafka/streams/kstream/Produced.html

可在此处找到 Partitioner 接口的实现示例: