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?