Skip to content
Connection Pooling for Reactive Relational Database Connectivity
Java Shell
Branch: master
Clone or download

Reactive Relational Database Connectivity Connection Pool Implementation

This project contains a R2DBC connection pool using reactor-pool for reactive connection pooling.


Both milestone and snapshot artifacts (library, source, and javadoc) can be found in Maven repositories.


Artifacts can be found at the following repositories.


    <name>Spring Snapshots</name>
    <name>Spring Milestones</name>


Configuration of the ConnectionPool can be accomplished in two ways:

Connection Factory Discovery

ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder()
   .option(DRIVER, "pool")
   .option(PROTOCOL, "h2") // driver identifier, PROTOCOL is delegated as DRIVER by the pool.
   .option(HOST, "")
   .option(PORT, "") 
   .option(USER, "")
   .option(PASSWORD, "")
   .option(DATABASE, "")

The delegated `DRIVER` (via `PROTOCOL`) above refers to the r2dbc-driver, currently one of `h2`, `postgresql`, `mssql`.

Publisher<? extends Connection> connectionPublisher = connectionFactory.create();

// Alternative: Creating a Mono using Project Reactor
Mono<Connection> connectionMono = Mono.from(connectionFactory.create());

Supported Connection Factory Discovery options:

Option Description
driver Must be pool
protocol Driver identifier. The value is propagated by the pool to the driver property.
maxSize Maximum pool size. Defaults to 10.
validationDepth Validation depth used to validate an R2DBC connection. Defaults to LOCAL.
validationQuery Query that will be executed just before a connection is given to you from the pool to validate that the connection to the database is still alive.

All other properties are driver-specific


ConnectionFactory connectionFactory = …;

ConnectionPoolConfiguration configuration = ConnectionPoolConfiguration.builder(connectionFactory)

ConnectionPool pool = new ConnectionPool(configuration);

Mono<Connection> connectionMono = pool.create();

// later

Connection connection = …;
Mono<Void> release = connection.close(); // released the connection back to the pool

// application shutdown


This project is released under version 2.0 of the Apache License.

You can’t perform that action at this time.