连续听一个话题,获取数据,进行一些基本的清洗

Listen to a topic continiously, fetch data, perform some basic cleansing

我要构建一个基于 Java 的 Kafka 流应用程序,它将连续收听主题 X、获取数据、执行一些基本清理并写入 Oracle 数据库。 kafka 集群在我的域之外,无法在其中部署任何代码或配置。

设计这种解决方案的最佳方法是什么?我遇到了 Kafka Streams,但对它是否可以用于 'Topic > Process > Topic' 场景感到困惑?

I came accross Kafka Streams but was confused as to if it can be used for 'Topic > Process > Topic' scenarios?

当然可以。

例如,排除 "process" 步骤,它是配置设置之外的两行。

final StreamsBuilder builder = new StreamsBuilder();
builder.stream("streams-plaintext-input").to("streams-pipe-output");

此代码直接来自 the documentation


如果您想写入任何数据库,您应该first check if there is a Kafka Connect plugin 为您完成。 Kafka Streams 不应该真正用于 read/write from/to Kafka 之外的外部系统,因为它对延迟敏感。

在您的情况下,the JDBC Sink Connector 会很好。

The kafka cluster is outside my domain and have no ability to deploy any code or configurations in it.

使用上面的任何一种解决方案,你都不需要,但你需要一些机器 Java 安装到 运行 一个连续的 Kafka Streams 应用程序 and/or Kafka Connect worker。