0

I am using spring xd to get data from a raw table and process it and then store it to multiple tables.

I got success to store in to one tables.

The problem i am facing is how to store data to mutiple tables using Spring XD sink jdbc.

Currently I am creating stream through following code. It will fetch data from raw table(raw_device_data) and after processing it is storing it to sleep_analysis table.

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

I want to store the processed data to multiple tables.

Thanks.

Aman Agrawal
  • 95
  • 1
  • 1
  • 10

1 Answers1

1

Send the result to a topic named channel. Create two (or more) streams to consume from that topic - see the documentation.

foo | bar > topic:result

topic:result > jdbc1

topic:result > jdbc2
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • I have to insert raw data in to two tables. and one of them having the foreign dependency of other. so how do pass the id of first tables to another. – Aman Agrawal Sep 22 '16 at 09:14
  • In that case you'll need a custom JDBC sink. – Gary Russell Sep 22 '16 at 12:43
  • I check this example to create custom sink. http://stackoverflow.com/questions/35578688/how-to-implement-a-spring-xd-sink but how i can do insert rows in java method. – Aman Agrawal Sep 23 '16 at 07:27
  • Use a [JdbcTemplate](http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/jdbc.html). – Gary Russell Sep 23 '16 at 12:40