从数据库查询结果创建 Flink DataStream

发布于 2025-01-14 18:41:19 字数 458 浏览 3 评论 0原文

在我的问题中,我需要查询数据库并将查询结果与 Flink 中的 Kafka 数据流连接起来。目前,这是通过将查询结果存储在文件中,然后使用 Flink 的 readFile 功能创建查询结果的 DataStream 来完成的。有什么更好的方法可以绕过写入文件的中间步骤并直接从查询结果创建 DataStream

我目前的理解是,我需要按照建议编写一个自定义 SourceFunction 此处。这是正确且唯一的方法还是有其他选择?

是否有任何好的资源可用于编写自定义 SoruceFunctions 或者我应该查看当前的实现以供参考并根据我的需求自定义它们?

In my problem I need to query a database and join the query results with a Kafka data stream in Flink. Currently this is done by storing the query results in a file and then use Flink's readFile functionality to create a DataStream of query results. What could be a better approach to bypass the intermediary step of writing to file and create a DataStream directly from query results?

My current understanding is that I would need to write a custom SourceFunction as suggested here. Is this the right and only way or are there any alternatives?

Are there any good resources for writing the custom SoruceFunctions or should I just look at current implementations for reference and customise them fro my needs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心碎的声音 2025-01-21 18:41:19

一种简单的解决方案是使用 查找连接,也许使用 缓存已启用。

其他可能的解决方案包括 kafka connect,或使用 Debezium 之类的工具将数据库表镜像到 Flink 中。这是一个示例: https://github.com/ververica/flink-sql-CDC

One straightforward solution would be to use a lookup join, perhaps with caching enabled.

Other possible solutions include kafka connect, or using something like Debezium to mirror the database table into Flink. Here's an example: https://github.com/ververica/flink-sql-CDC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文