从数据库查询结果创建 Flink DataStream
在我的问题中,我需要查询数据库并将查询结果与 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种简单的解决方案是使用 查找连接,也许使用 缓存已启用。
其他可能的解决方案包括 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.