【发布时间】:2020-05-26 16:55:25
【问题描述】:
我有一个使用 apache flink 处理数据流信号的 SpringBoot gradle 项目。当一个新信号通过数据流时,我想使用已经创建的 postgres 数据库表中的 ID 查询查找(即 findById() )它的详细信息,以便获取有关信号的其他信息并丰富数据。我想避免使用 spring 依赖项来执行查找(即 Autowire 存储库),并希望坚持使用 flink 实现进行查找。
我在哪里可以指定如何添加 postgres 连接配置信息,例如端口、数据库、url、用户名、密码等...(为简单起见,可以假设 postgres db 在我的机器上是本地的)。是否像在 application.properties 文件中添加配置一样简单?如果是这样,我如何编写查询方法以在非主键值搜索时查找 postgres 表中的记录?
一些在线资源建议使用此框架代码,但我不确定它如何/id 适合我的用例。 (我创建了一个 EventEntity 模型,其中包含我正在查找的表中的所有参数/列)。
like so
public class DatabaseMapper extends RichFlatMapFunction<String, EventEntity> {
// Declare DB connection & query statements
public void open(Configuration parameters) throws Exception {
//Initialize DB connection
//prepare query statements
}
@Override
public void flatMap(String value, Collector<EventEntity> out) throws Exception {
}
}
【问题讨论】:
标签: java postgresql spring-boot apache-flink flink-streaming