我正在使用 spring xd 从原始表中获取数据并对其进行处理,然后将其存储到多个表中。
我成功存储到一张表中。
我面临的问题是如何使用Spring XD接收器jdbc将数据存储到多个表。
目前我正在通过以下代码创建流。它将从原始表(raw_device_data)中获取数据,并在处理后将其存储到 sleep_analysis 表中。
stream create db --definition "source:jdbc --query='select data from raw_device_data where id=330' --url=jdbc:postgresql://localhost:5432/rahar --driverClassName=org.postgresql.Driver --username=postgres --password=root --outputType=application/json | customProcessor15 | sink:jdbc --tableName=sleep_analysis --initializeDatabase=true --columns=latency,sleep_duration,sleep_efficiency,total_minutes_in_bed,total_sleep_time,wakefulness --url=jdbc:postgresql://localhost:5432/rahar --driverClassName=org.postgresql.Driver --username=postgres --password=root" --deploy
我想将处理后的数据存储到多个表中。
谢谢。
最佳答案
将结果发送到topic
命名 channel 。创建两个(或更多)流以从该主题使用 - 请参阅the documentation .
foo | bar > topic:result
topic:result > jdbc1
topic:result > jdbc2
关于java - 如何通过 Spring XD Sink 处理一些数据并将其存储到多个表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39617116/