oracle / oracle-r2dbc

R2DBC Driver for Oracle Database
https://oracle.com
Other
197 stars 40 forks source link

Spring + Oracle r2dbc and r2dbc pool #70

Closed 7Mircea closed 2 years ago

7Mircea commented 2 years ago

@neibarbosa Thanks for sharing this. Providing a code sample and details about how to recreate the issue is very much appreciated!

I think that you are testing with the 0.1.0 version of Oracle R2DBC. Is this correct? The 0.1.0 release did not integrate with r2dbc-pool for the reason you have noticed: The Publisher returned by ConnectionFactory.create() did not support multiple subscribers. The r2dbc-pool project expects the Publisher to support multiple subscribers.

In the 0.2.0 release, we fixed this so that multiple subscribers are now supported. With this fix, Oracle R2DBC should now work with r2dbc-pool. The pull request for that fix is here: #24

You might want to try testing with oracle-r2dbc:0.2.0 and r2dbc-pool:0.9.0.M1. These versions both support the 0.9.0.M1 R2DBC SPI.

Originally posted by @Michael-A-McMahon in https://github.com/oracle/oracle-r2dbc/issues/29#issuecomment-883860756

I understand that I have to use oracle-r2dbc:0.2.0 and r2dbc-pool:0.9.0.M1 together. However I am using Spring and according to their README.md I cannot use oracle-r2dbc:0.2.0, but oracle-r2dbc:0.1.0. What version should I use to for these dependencies to use them with Spring? I've created a project for testing https://github.com/7Mircea/R2dbc_Oracle_Spring.

Michael-A-McMahon commented 2 years ago

I wonder if an r2dbc-bom dependency would straighten this out? https://github.com/r2dbc/r2dbc-bom

The BOM groups together compatible versions of r2dbc-pool and oracle-r2dbc. So rather than declare dependencies on r2dbc-spi, r2dbc-pool, oracle-r2dbc, and ojdbc11, you could just declare one dependency:

<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-bom</artifactId>
<version>Borca-SR1</version>

I have almost no experience using Spring though, so I might be missing something. Maybe @mp911de can offer some insight?

7Mircea commented 2 years ago

I checked that version but because I use Spring I cannot use more than version 0.1.0 and in r2dbc-bom-Borca-SR1.pom is this line <r2dbc-oracle.version>0.4.0</r2dbc-oracle.version> so I used Arabba-SR13. Still i get 'This publisher does not support multiple subscribers' when testing the project with multiple concurrent HTTP requests(I've used Jmeter for testing with 400 users). The project however worked perfectly when tested with 100 concurrent users. I'm refering to the same project I mentioned earlier, but now the commit is edcadce

7Mircea commented 2 years ago

It's now working, sorry for inconvenience. Using the dependency you told me worked really well. I was using an old version for spring-boot-starter-parent and that was also causing problems. Thank you very much!

mp911de commented 2 years ago

Spring Data R2DBC 1.5 (can be consumed through Spring Boot 2.7) has upgraded to R2DBC 0.9 (Borca release train). Earlier Spring Data/Boot versions require R2DBC 0.8 (Arabba release train). Does that help?

mofeed-hassan commented 2 years ago

@7Mircea I understand that using dependency

io.r2dbc r2dbc-bom Borca-SR1

solved the multiple subscriber problem, but did not you get the deprecated method exception regarding getColumnsName()? As I got it. To clarify my case I am using R2DBC in Spring to accessing oracle DB with oracle-r2dbc and r2dbc pool. I am using a Java repository with a sql statement then method bufferUntilChange() to collect data. I get the multiple subscriber exception. I used the mentioned bom version but it raises deprecated method. Now I am stuck.

7Mircea commented 2 years ago

I've got a similar problem when I moved to Borca-SR1 with ConnectionFactoryInitializer being marked as deprecated(it was from org.springframework.data:spring-data-r2dbc:1.5.0) so I used another import statement import org.springframework.r2dbc.connection.init.ConnectionFactoryInitializer;(that uses org.springframework:spring-r2dbc:5.3.20). The repository I used was extending ReactiveCrudRepository<Class_name,Primary_Key_Type> from org.springframework.data:spring-data-commons:2.7.0. In my case Class_name=Produse,Primary_Key_Type=Integer. Produse(english:Products) was a personal plain old java object. Did you try extending it?

mofeed-hassan commented 2 years ago

@7Mircea No I did not. In my case the code was like that: @Repository public class MyCustomRepository { private static final String query ="..."; private final DatabaseClient databaseClient; //org.springframework.r2dbc.core.DatabaseClient this.databaseClient.sql(query) // .bind("fName", fName) // .bind("lName", lName) // .fetch().all() // s .bufferUntilChanged(person -> person.get("id")) // .map(.......) } which part should I replace to avoid callin ghte old version of getColumnNames()? It seems it is called internally some how.