datastax / cassandra-quarkus

An Apache Cassandra(R) extension for Quarkus
Apache License 2.0
40 stars 28 forks source link

Update (quickstart guide) to recent extension / Quarkus version #212

Closed Alexander-Krause-Glau closed 1 year ago

Alexander-Krause-Glau commented 1 year ago

I think Github Discussions are not enabled for this repo, therefore, I write this issue. Are there any plans to update this extension to a recent Quarkus version? I changed the Quarkus version in your pom.xml and get a lot of errors.

I come up with this because of an issue that I have in my application. After updating, I get

java.lang.IllegalArgumentException: Found no registered MapperResultProducer that can produce io.smallrye.mutiny.Uni<Void>

for the insert operation of my DAO.

┆Issue is synchronized with this Jira Task by Unito

adutra commented 1 year ago

Hi @Alexander-Krause-Glau thanks for raising this issue. I am about to open a PR to upgrade the extension to Quarkus 2.15 and driver 4.15.

However, I am not seeing the error you mentioned. Do you have a small reproducible test case? Thanks!

Alexander-Krause-Glau commented 1 year ago

Hi @adutra,

thank you for your response. Here are some details to reproduce this (with our OSS):

  1. Clone our tool and checkout the fix-int-test-old-approach branch.
  2. Run ./gradlew assemble integrationTest to run our narrow integrationtests (normally, they would probably fail now, because, they are not adopted to the latest updates). This should result in the mentioned error (among others).

I saw the application code for your integration tests and thought that there might be something wrong with the code above. I tried to rebuild your @Mapper interface and the approach on a different branch, but when executing ./gradlew clean assemble I now receive

Invalid return type: DaoFactory methods must return a Dao-annotated interface, or future thereof

I thought that there might be a problem with my DI producer, but I couldn't find a counterpart in your integration tests or the Quarkus Cassandra guide. I remember that there was such a part in guide in the past and found it in an old commit: https://github.com/datastax/cassandra-quarkus/commit/b7e3615cf903497c6331933743456b74e6b8ff05

So, I also deleted the Producer and created a new branch: https://github.com/ExplorViz/landscape-service/tree/fix-int-tests-without-producer

Running ./gradlew clean assemble results in the same Invalid return type... error. Can you see what I am doing wrong?

Alexander-Krause-Glau commented 1 year ago

Hi @adutra ,

today I saw that you added a new dependency in the linked commit. Adding the following to my Gradle project

annotationProcessor group: 'com.datastax.oss.quarkus', name: 'cassandra-quarkus-mapper-processor', version: '1.1.2' fixed the problem (when using the "new approach" for the ReactiveService, i.e., using Uni<ReactiveService>).

However, this new approach is not documented in the Quickstart guide, right? I am not sure why I should use Uni<ReactiveService> instead of ReactiveService. I updated the title of the issue a little bit.

adutra commented 1 year ago

@Alexander-Krause-Glau I think I see the issue.

It seems you are not using the cassandra-quarkus-mapper-processor to generate the mapper classes, instead you are using java-driver-mapper-processor. The driver's annotation processor cannot generate Quarkus-specific stuff, such as bean producers, or beans of type Uni. For that, you need to use the Quarkus Cassandra mapper processor.

See here:

https://github.com/ExplorViz/landscape-service/blob/2a2894912ecc38aa26b304b7152370cf914e019b/build.gradle#L64

Change that line to:

  annotationProcessor group: 'com.datastax.oss.quarkus', name: 'cassandra-quarkus-mapper-processor', version: "${quarkusCassandraPlatformVersion}"

Let me know if that helps.

Alexander-Krause-Glau commented 1 year ago

Hi @adutra I think you did not refresh the browser tab for this issue. I also found this dependency as mentioned in the answer above your last comment. But as far as I can see, there is a offset between the guide and the code that I now use.

adutra commented 1 year ago

Ah, it seems our messages got crossed :-)

However, this new approach is not documented in the Quickstart guide, right? I am not sure why I should use Uni instead of ReactiveService.

It might not be well documented, but the issue is covered in the section called "Eager vs Lazy Initialization".

It's perfectly fine to keep injecting ReactiveService, however depending on how your application is built, you might run into an issue with lazy initialization. If you see errors messages saying "Thread blocked", you need to enable eager initialization to fix it.

adutra commented 1 year ago

But yes, the right mapper annotation processor to use is indeed not mentioned in the quickstart guide, I will update it.

Alexander-Krause-Glau commented 1 year ago

Thank you ! Let's keep this issue open so that you can reference it in your PR.