Webflux postgresql

2019-07-14 20:51发布

How should I implement postgresql in Webflux?
I would like to do it with ReactiveCrudRepository, but JPA isn't reactive... I want to store users and SSH public and private keys. I've read that MongoDB transactions aren't as reliable as postgresql(Correct me if I am wrong). Thats why I want to use postgresql.

But what is the best way to use Postgresql in webflux? I would like to use JPA repositories(or other) and not write full queries, but still be able to program reactively.

2条回答
我想做一个坏孩纸
2楼-- · 2019-07-14 21:10

Still no official driver for Pg. I didn't really use it but here is a try at this github link.

Take a look at Redis as an alternative to mongodb: It can be both in memory db and ordinary datasource.

Hope was helpful :)

查看更多
Luminary・发光体
3楼-- · 2019-07-14 21:27

There is no "official" reactive JDBC driver yet (as of March 2019). However, there are many 3rd party reactive drivers for postgres. I used David Moten's rxjava2-jdbc library and postgres jdbc driver

I wrote a tutorial/example using webflux, kotlin and postgres (rxjava2-jdbc) here: https://medium.com/@dvliman/building-a-reactive-web-service-with-spring-webflux-kotlin-and-postgresql-71c4e0c2f870

and the source code here: https://github.com/dvliman/spring-webflux-kotlin-postgresql/

but I wasn't using JPA - I would manually marshall data, write queries/functions to operate on the data.

查看更多
登录 后发表回答