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

Update to MongoDB Java driver 4.0.0 #7868

Merged
merged 1 commit into from
Mar 24, 2020

Conversation

Postremus
Copy link
Member

We definitely want a note about this change in the migration guides.
The interface changes for reactive mongo most likely break user applications.

See also the mongo java driver 4.0 upgrade guide: https://mongodb.github.io/mongo-java-driver/4.0/upgrading

@boring-cyborg boring-cyborg bot added area/dependencies Pull requests that update a dependency file area/mongodb area/panache labels Mar 14, 2020
@gsmet gsmet requested review from cescoffier and loicmathieu March 14, 2020 18:58
@loicmathieu
Copy link
Contributor

I will try this one on some projects I have that uses more Mongodb functionalities before approving this. I want to be sure that everything works as before with this new major version of the client

Copy link
Member

@cescoffier cescoffier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added one comment about the new "TDocument" thingy.

Also, do you know why https://docs.mongodb.com/ecosystem/drivers/java/ has not been updated with this version? I would like to be sure we don't lose support for some MongoDB version. If we do we must document it.

@@ -478,7 +502,7 @@
* @param pipeline the aggregate pipeline
* @return a stream containing the result of the aggregation operation
*/
AggregatePublisher<Document> aggregateAsPublisher(List<? extends Bson> pipeline);
AggregatePublisher<T> aggregateAsPublisher(List<? extends Bson> pipeline);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this should be considered as a breaking change.
Initially, it only contained Document, now it can be any type.

First I would use TDocument as in the driver to indicate that it's not any type, but must be somehow a document. The lack of constraint in the driver is a bit odd.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cescoffier TDocument means any type T that can be converted to a document. I agree this is a bit odd as it didn't convey any constraint. As we register the Pojo Codec, almost any type can be converted automatically (except for some deep generic types). So maybe T is OK.

@Postremus
Copy link
Member Author

@cescoffier

No Idea why the table on the official site was not updated.
In https://mongodb.github.io/mongo-java-driver/4.0/upgrading/#compatibility, It has the new 4.0 driver, with same compatibility as our old 3.12.0.

Copy link
Contributor

@loicmathieu loicmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I check some internal projects (including some basic Kotlin ones) and all works without issue.

It is worth noting that the uber client is no longer available, but as we switch to the new clients in the previous release this should not be an issue.

It is also worth noting that quarkus-camel also provides MongoDB support, maybe we should check on their side before merging this one, @gsmet ?

@gastaldi
Copy link
Contributor

It is also worth noting that quarkus-camel also provides MongoDB support, maybe we should check on their side before merging this one, @gsmet ?

Maybe @ppalaga or @lburgazzoli can confirm?

@ppalaga
Copy link
Contributor

ppalaga commented Mar 16, 2020

It is also worth noting that quarkus-camel also provides MongoDB support, maybe we should check on their side before merging this one, @gsmet ?

Maybe @ppalaga or @lburgazzoli can confirm?

@jamesnetherton is our Mongo expert

@jamesnetherton
Copy link
Contributor

I ran the camel-quarkus integration tests with this change...

Unfortunately, the camel-mongo component is currently tied to the 3.x drivers and there are API changes in 4.x which seem to break things. E.g:

Caused by: java.lang.NoSuchMethodError: com.mongodb.client.MongoCollection.insertOne(Ljava/lang/Object;)V
	at org.apache.camel.component.mongodb.MongoDbProducer.lambda$createDoInsert$7(MongoDbProducer.java:437)
	at org.apache.camel.component.mongodb.MongoDbProducer.lambda$wrap$0(MongoDbProducer.java:256)
	at org.apache.camel.component.mongodb.MongoDbProducer.invokeOperation(MongoDbProducer.java:136)
	at org.apache.camel.component.mongodb.MongoDbProducer.process(MongoDbProducer.java:123)

What we probably want, is a camel-mongo4 component which uses the newer Mongo libs and APIs. I can't say how much effort that'd be or when we're likely to have that though.

@loicmathieu
Copy link
Contributor

@jamesnetherton it's surprising because we do use insertOne inside MongoDB with Panache:

Did you check that you don't have a dependency issue and that all mongodb related libraries are of version 4 ?

@jamesnetherton
Copy link
Contributor

@loicmathieu you're right, I think it should work.

Dependencies look fine:

[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ camel-quarkus-integration-test-mongodb ---
[INFO] org.apache.camel.quarkus:camel-quarkus-integration-test-mongodb:jar:1.1.0-SNAPSHOT
[INFO] \- org.apache.camel.quarkus:camel-quarkus-mongodb:jar:1.1.0-SNAPSHOT:compile
[INFO]    +- io.quarkus:quarkus-mongodb-client:jar:999-SNAPSHOT:compile
[INFO]    |  +- org.mongodb:mongodb-driver-sync:jar:4.0.0:compile
[INFO]    |  \- org.mongodb:mongodb-driver-reactivestreams:jar:4.0.0:compile
[INFO]    +- org.mongodb:mongodb-driver-legacy:jar:4.0.0:compile
[INFO]    |  +- org.mongodb:bson:jar:4.0.0:compile
[INFO]    |  \- org.mongodb:mongodb-driver-core:jar:4.0.0:compile
[INFO]    \- org.mongodb:mongodb-crypt:jar:1.0.0:compile

Here's the failure point:

https://github.com/apache/camel/blob/master/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java#L437

I'll have to try and dig into it a bit more.

@jamesnetherton
Copy link
Contributor

It works when the camel component is compiled against the 4.x libs, otherwise we hit the NoSuchMethodError.

So I think we need a 4.x compatible camel component for this to work.

@loicmathieu
Copy link
Contributor

@jamesnetherton we will need a coordinated release for Quarkus and Camel-Quarkus, but it's always the case right ?
So this will works if you do the same on your side and we both target the same release.

@jamesnetherton
Copy link
Contributor

@loicmathieu yes, I created a Camel issue to track the upgrade work.

@gastaldi gastaldi added this to the 1.4.0 milestone Mar 23, 2020
@gastaldi
Copy link
Contributor

Is this PR OK to be merged?

@Postremus
Copy link
Member Author

@jamesnetherton
I see that your camel pr is merged.
Can we upgrade to the 4.0 of the java driver in quarkus 1.4.0, or should we wait?

@jamesnetherton
Copy link
Contributor

@ppalaga @lburgazzoli do you think this is ok to be merged? The Camel changes wont be available until 3.2.0 is released, so we'd be blocked upgrading Quarkus to 1.4.0 until it's available.

@jamesnetherton
Copy link
Contributor

Let's not hold this back any longer. I'm ok for it to be merged 👍

@gastaldi gastaldi merged commit de1b210 into quarkusio:master Mar 24, 2020
@Postremus Postremus deleted the mongo-driver-4 branch March 24, 2020 11:27
@gsmet gsmet changed the title Update to mongo java driver 4.0.0 Update to MongoDB Java driver 4.0.0 Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants