Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support async datasource drivers #38

Open
Dudeplayz opened this issue Dec 7, 2021 · 9 comments
Open

Support async datasource drivers #38

Dudeplayz opened this issue Dec 7, 2021 · 9 comments

Comments

@Dudeplayz
Copy link

Dudeplayz commented Dec 7, 2021

How does it look with the support for the async drivers? Jooq has support for it since 3.15 jOOQ/jOOQ#6298
https://blog.jooq.org/tag/async/

My project is currently based on vertx-jooq and I'd like to migrate the whole app to quarkus. My db calls are async reactive atm and updating to quarkus would result in going back to jdbc. I know that I could still use vertx-jooq, but I would like to use a "from one hand" solution.

@lukaseder
Copy link

jOOQ 3.15 supports R2DBC, which isn't based on the vertx drivers. I do hope that vertx will team up with R2DBC to implement their SPI to create that "from one hand" situation, knowing that reactive != async, though...

@Dudeplayz
Copy link
Author

Hello @lukaseder, nice to meet you. At first, you're doing a very great job, If I search for something related with jooq, I see in 90% of the cases a very detailed answer from you. So thanks for that! (I also linked the jooq issue, in expectation to get an answer from you.)

jOOQ 3.15 supports R2DBC, which isn't based on the vertx drivers. I do hope that vertx will team up with R2DBC to implement their SPI to create that "from one hand" situation, knowing that reactive != async, though...

I corrected my question. I am using the reactive way, It seems I'm using it a bit wrong :).
Ok, so I hope that vertx will support r2dbc. There are some related issues eclipse-vertx/vertx-sql-client#249 eclipse-vertx/vertx-sql-client#245. But sadly it isn't that active, how I'd like to see.

I'm right, that if I use the JooqCustomContext in this project and configure it to use R2DBC (adding the driver), then I should be able to use the async calls from Jooq?

@lukaseder
Copy link

I'm right, that if I use the JooqCustomContext in this project and configure it to use R2DBC (adding the driver), then I should be able to use the async calls from Jooq?

Probably... Well, let us know if it works :)

@Dudeplayz
Copy link
Author

Dudeplayz commented Dec 7, 2021

I got it working after some drawbacks. I published a repo with the code (Kotlin). I implemented both configuration options mentioned in the docs. I am a bit unsure if it is using the R2DBC driver, but the errors I got were related to the R2DBC driver. Maybe you can have a quick look @lukaseder ?

For Agroal there has to be a JDBC implementation present at runtime. Are NO-OP JDBC drivers existing? I haven't found one.
Without the hard dependency on Agroal it may be working without it.

Also the native compilation may not working anymore.

@lukaseder
Copy link

What am I looking for?

lukas@LAPTOP-VH130UJV MINGW64 ~/jOOQ/mcve/quarkus-jooq-r2dbc-example
$ mvn clean install
08:40:51,105 [INFO] Scanning for projects...
08:40:52,321 [INFO]
08:40:52,323 [INFO] ---------------< com.example:quarkus-jooq-r2dbc-example >---------------
08:40:52,327 [INFO] Building quarkus-jooq-r2dbc-example 1.0-SNAPSHOT
08:40:52,330 [INFO] --------------------------------[ jar ]---------------------------------
08:40:53,066 [INFO]
08:40:53,068 [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ quarkus-jooq-r2dbc-example ---
08:40:53,126 [INFO] Deleting C:\Users\lukas\jOOQ\mcve\quarkus-jooq-r2dbc-example\target
08:40:53,192 [INFO]
08:40:53,195 [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ quarkus-jooq-r2dbc-example ---
08:40:53,355 [INFO] Using 'UTF-8' encoding to copy filtered resources.
08:40:53,363 [INFO] Copying 2 resources
08:40:53,374 [INFO]
08:40:53,375 [INFO] --- quarkus-maven-plugin:2.5.1.Final:generate-code (default) @ quarkus-jooq-r2dbc-example ---
08:40:54,750 [INFO]
08:40:54,752 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ quarkus-jooq-r2dbc-example ---
08:40:54,975 [INFO] Nothing to compile - all classes are up to date
08:40:54,978 [INFO]
08:40:54,979 [INFO] --- kotlin-maven-plugin:1.5.31:compile (compile) @ quarkus-jooq-r2dbc-example ---
08:40:56,012 [INFO] Applied plugin: 'all-open'
08:41:00,701 [INFO]
08:41:00,703 [INFO] --- quarkus-maven-plugin:2.5.1.Final:generate-code-tests (default) @ quarkus-jooq-r2dbc-example ---
08:41:02,060 [INFO]
08:41:02,062 [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ quarkus-jooq-r2dbc-example ---
08:41:02,070 [INFO] Using 'UTF-8' encoding to copy filtered resources.
08:41:02,073 [INFO] skip non existing resourceDirectory C:\Users\lukas\jOOQ\mcve\quarkus-jooq-r2dbc-example\src\test\resources
08:41:02,078 [INFO]
08:41:02,079 [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ quarkus-jooq-r2dbc-example ---
08:41:02,090 [INFO] Changes detected - recompiling the module!
08:41:02,098 [INFO]
08:41:02,100 [INFO] --- kotlin-maven-plugin:1.5.31:test-compile (test-compile) @ quarkus-jooq-r2dbc-example ---
08:41:02,114 [INFO] Applied plugin: 'all-open'
08:41:02,834 [INFO]
08:41:02,835 [INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ quarkus-jooq-r2dbc-example ---
08:41:03,248 [INFO]
08:41:03,249 [INFO] -------------------------------------------------------
08:41:03,252 [INFO]  T E S T S
08:41:03,253 [INFO] -------------------------------------------------------
08:41:04,099 [INFO] Running com.example.ExampleResourceTest
2021-12-08 08:41:09,435 INFO  [io.quarkus] (main) Quarkus 2.5.1.Final on JVM started in 2.715s. Listening on: http://localhost:8081
2021-12-08 08:41:09,437 INFO  [io.quarkus] (main) Profile test activated.
2021-12-08 08:41:09,437 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, jdbc-h2, kotlin, narayana-jta, resteasy-reactive, resteasy-reactive-jackson, smallrye-context-propagation, vertx]
08:41:10,742 [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.615 s - in com.example.ExampleResourceTest
2021-12-08 08:41:10,763 INFO  [io.quarkus] (main) Quarkus stopped in 0.055s
08:41:10,895 [INFO]
08:41:10,897 [INFO] Results:
08:41:10,899 [INFO]
08:41:10,900 [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
08:41:10,902 [INFO]
08:41:10,908 [INFO]
08:41:10,909 [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ quarkus-jooq-r2dbc-example ---
08:41:11,075 [INFO] Building jar: C:\Users\lukas\jOOQ\mcve\quarkus-jooq-r2dbc-example\target\quarkus-jooq-r2dbc-example-1.0-SNAPSHOT.jar
08:41:11,099 [INFO]
08:41:11,101 [INFO] --- quarkus-maven-plugin:2.5.1.Final:build (default) @ quarkus-jooq-r2dbc-example ---
08:41:11,640 [INFO] [org.jboss.threads] JBoss Threads version 3.4.2.Final
08:41:12,971 [INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 1856ms
08:41:12,988 [INFO]
08:41:12,989 [INFO] --- maven-install-plugin:2.4:install (default-install) @ quarkus-jooq-r2dbc-example ---
08:41:13,057 [INFO] Installing C:\Users\lukas\jOOQ\mcve\quarkus-jooq-r2dbc-example\target\quarkus-jooq-r2dbc-example-1.0-SNAPSHOT.jar to C:\Users\lukas\.m2\repository\com\example\quarkus-jooq-r2dbc-example\1.0-SNAPSHOT\quarkus-jooq-r2dbc-example-1.0-SNAPSHOT.jar
08:41:13,070 [INFO] Installing C:\Users\lukas\jOOQ\mcve\quarkus-jooq-r2dbc-example\pom.xml to C:\Users\lukas\.m2\repository\com\example\quarkus-jooq-r2dbc-example\1.0-SNAPSHOT\quarkus-jooq-r2dbc-example-1.0-SNAPSHOT.pom
08:41:13,088 [INFO] ------------------------------------------------------------------------
08:41:13,092 [INFO] BUILD SUCCESS
08:41:13,093 [INFO] ------------------------------------------------------------------------
08:41:13,098 [INFO] Total time:  22.014 s
08:41:13,100 [INFO] Finished at: 2021-12-08T08:41:13+01:00
08:41:13,102 [INFO] ------------------------------------------------------------------------

@Dudeplayz
Copy link
Author

  1. If I correctly called the reactive way of jooq.
  2. If the correct driver is used at runtime. I haven't found a good way to track that. But I think this is not necessary, I don't want to waste your time.

@lukaseder
Copy link

  1. If I correctly called the reactive way of jooq.

You only wrote one query, I think, and it's this? https://github.com/Dudeplayz/quarkus-jooq-r2dbc-example/blob/master/src/main/kotlin/com/example/JooqResource.kt

What could possibly be wrong about it?

2. If the correct driver is used at runtime. I haven't found a good way to track that.

What made you think your driver usage wasn't correct?

@Dudeplayz
Copy link
Author

You only wrote one query, I think, and it's this? https://github.com/Dudeplayz/quarkus-jooq-r2dbc-example/blob/master/src/main/kotlin/com/example/JooqResource.kt

Yes, other calls would be analog?

What made you think your driver usage wasn't correct?

My first tries were executed with the wrong driver. But I think this should be fixed. If I use it at runtime I would discover it when I use the H2 as the default JDBC driver and use Postgres as the R2DBC driver. Also I was using executeAsync at first and not the query builder as publisher.

@lukaseder
Copy link

Yes, other calls would be analog?

Yes. Always use jOOQ queries as Publisher<Integer> or Publisher<R extends Record>

Also I was using executeAsync at first and not the query builder as publisher.

That doesn't get backed by R2DBC yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants