Spring Data R2DBC [PostgreSQL]
R2DBC (Reactive Relational Database Connectivity) is a Reactive API open specification that establishes a Service Provider Interface (SPI) for database drivers. It allows drivers to provide a fully reactive non-blocking integration with databases, which means, it enables you to move from the classic one thread per connection model to a more powerful and scalable approach. Queries are written to the socket and then the thread can continue processing other stuff until a response has been received which leads to less resource overhead.
This post discuss R2DBC driver implementation for PostgreSQL and how it’s integrates with Spring Data Framework.
1. R2DBC Service Provider Interface (SPI)
The R2DBC SPI provides reactive programmatic access to relational databases from the Java and other JVM-based programming languages. The SPI is not intended for direct use from the application code, R2DBC SPI aims for being primarily consumed though client library implementations. The R2DBC API Compliance can be found here R2DBC spec.
2. R2DBC PostgreSQL Driver
In this section, we explore R2DBC driver implementation for PostgreSQL. It’s founded on the popular Netty framework for asynchronous communication via the PostgreSQL wire protocol.