Skip to content

How to route R2DBC calls to different data sources? #1261

Closed
@danilodeLuca

Description

@danilodeLuca

i'm trying to use 2 different data sources in the same project: readWrite(RW) and readOnly(RO), each one having its own instance host.
To do that I have configured RW data source as default, using spring-r2dbc properties and dependency, and it works fine.
But when trying to configure a RO it does not have any property support, so I manually configured the connectionFactory and DatabaseClient with RO properties, like the following code.

Configuring this new connection and databaseClient (RO) for some reason the connection pool is using this config instead of just using the default configurable in the application (the pool is composed by RW and RO connection). Is there some way to force pool to ignore it? Or a way to do that?

Versions:
io.r2dbc:r2dbc-postgresql:0.8.11.RELEASE
io.r2dbc:r2dbc-pool:0.8.8.RELEASE
org.springframework.boot:spring-boot-starter-data-r2dbc:2.6.6

image

Spring application.properties:
image

Metadata

Metadata

Assignees

Labels

for: stackoverflowA question that's better suited to stackoverflow.com

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions