简体   繁体   中英

Failed to obtain R2DBC, this publisher does not support multiple subscribers

I try to run r2dbc application with spring-boot-starter-data-r2dbc and oracle-r2dbc but it gives me an exception " org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection; nested exception is java.lang.IllegalStateException: This publisher does not support multiple subscribers".

Here is my properties file:

spring.r2dbc.url=r2dbc:oracle:thin://localhost:1521:orcl
spring.r2dbc.username=user
spring.r2dbc.password=password

and dependenices part of gradle file:

dependencies {
    ktlint 'com.pinterest:ktlint:0.41.0'
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
    implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
    implementation('com.fasterxml.jackson.module:jackson-module-kotlin')
    implementation('org.codehaus.janino:janino')
    implementation('org.springframework.cloud:spring-cloud-starter-stream-kafka')
    implementation('org.springframework.cloud:spring-cloud-stream')
    implementation('org.springframework.boot:spring-boot-configuration-processor')
    implementation('org.apache.httpcomponents:httpclient:4.5.8')
    implementation('org.springframework.retry:spring-retry')
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    implementation('org.springframework.boot:spring-boot-starter-data-r2dbc')
    implementation('com.oracle.database.r2dbc:oracle-r2dbc')
    implementation('com.oracle.database.jdbc:ojdbc11:21.1.0.0')
}

Here the part code causes error:

message.flatMap { fromMessage ->
                Mono
                    .zip(
                        listOf(
                            dimensionAdviserRepository
                                .findFirstByEntityIdOrderByFromDateDescToDateDesc(message.adviserKey)
                                .map { it?.adviserKey ?: -1L }
                                .switchIfEmpty(Mono.just(-1L)),
                            dimensionAccountRepository
                                .findFirstByEntityIdOrderByFromDateDescToDateDesc(fromMessage.accountKey!!)
                                .map { it?.account_key ?: -1L }
                                .switchIfEmpty(Mono.just(-1L))
))}

Am I missing any configuration or is this a known limitation?

Looks like you yourself opened a ticket in the Oracle R2DBC Github repo with this exact issue after this question here, and got an answer.

Helping others having the same question:

This is a known limitation of version 0.1.0 of Oracle R2DBC. It has been fixed in version 0.2.0, but that version is targeting R2DBC SPI version 0.9, which is currently not supported by Spring Data R2DBC as it hasn't been released as general availability yet.

A GA release of R2DBC SPI version 0.9 is planned for 2021-12-06 , after this we can expect Spring Data R2DBC to implement support for it, making it possible to upgrade the Oracle R2DBC driver and get rid of this limitation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM