Spring XD Stream – PostgreSQL JDBC Sink

Spring XD JDBC sink can be used to insert message payload data into a relational database table. The tutorial will introduce you how to work with PostgreSQL JDBC Sink

Related Article: Spring XD Stream – How to start with Stream

I. Technologies for Spring XD – PostgreSQL JDBC Sink

– Spring XD 1.3.1.Release
– Postgresql 9.5

II. Practices

Create a stream http | jdbc

1. Start Spring XD with single-node mode

Open a CMD
Go to: ./spring-xd-1.3.1.RELEASE\xd\bin
Run xd-singlenode

2. Create a Stream

Before create a stream, create a sql file int_sink_postgre.sql in folder: \spring-xd-1.3.1.RELEASE\xd\config with content:

Go to: .\spring-xd-1.3.1.RELEASE\shell\bin
Run xd-shell

Then run:

initializeDatabase: whether the database initialization script should be run (boolean, default: false)
initializerScript: the name of the SQL script (in /config) to run if ‘initializeDatabase’ is set (String, default: init_db.sql)

spring-xd postgresql jdbc sink deploy

After deployed, a customer table is created in PostgreSQL

3. Check result

Use xd-shell, run command:

spring xd postgresql jdbc sink post-http

Now, use pgAdminIII, see on customer table

spring-xd postgresql jdbc sink post-http-result

By grokonez | September 24, 2016.

Last updated on June 4, 2017.

Related Posts

Got Something To Say:

Your email address will not be published. Required fields are marked *