KStream 从一个集群到多个集群

KStream from one cluster to many

我需要在我的 Kafka 集群中有一个 java 模块来接收消息,并且根据消息的两个字段,它会被丰富并发布到另一个 kafka 集群。我一直在研究 KStream API,但我找不到将东西发送到另一个集群的方法(不使用发布者库)。

有什么想法吗?我该怎么做?

谢谢!

I need to have one java module in my Kafka cluster that will get a message, and depending on two fields of the message, it would be enriched and published to another kafka cluster. I've been researching KStream API and I can't find a way to send things to another cluster (without using the publisher library).

目前,Kafka 的 Streams API 一次只与一个给定的集群交互。也就是说,您不能从 Kafka 集群 A 读取,然后使用 Streams API.

写入 Kafka 集群 B

Any ideas and how can I do this?

因此,我建议为此使用 Kafka Connect。最新版本的 Kafka 在 Kafka Connect 中包含所谓的 Single Message Transformations 功能,您可以使用它来路由消息。

如果您愿意使用商业工具,Confluent Replicator (docs) 允许您执行此类跨集群数据流,如 Hans Jespersen 上面提到的。

一个很好的高级起点是 Single Message Transformations Are Not the Transformations You’re Looking For (don't be deterred by the title :-P) by Ewen Cheslack-Postava, one of the Kafka committers who developed the new SMT feature. There's also a blog post 简要描述 Kafka Connect 中的 SMT 的演讲。