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

DATAMONGO-2427 - Upgrade to MongoDB Driver 4.0 Snapshot #823

Closed
wants to merge 10 commits into from

Conversation

christophstrobl
Copy link
Member

This ⚠️ breaking ⚠️ change switches to the MongoDB 4.0 driver and introduces configuration options for com.mongodb.client.MongoClient.
The XML namespace changes from client-options to client-settings and removes already deprecated elements and attributes.

Imports are switched from single artifact uber jar (mongo-java-driver) to split imports for driver-core, -sync and -reactivestreams (one of the latter 2 required).

API deprecations from previous versions have now been removed.

Changed Java API

Type Comment
MongoClientFactoryBean Creates com.mongodb.client.MongoClient instead of com.mongodb.MongoClient. Uses MongoClientSettings instead of MongoClientOptions.
MongoDataIntegrityViolationException Uses WriteConcernResult instead of WriteResult.
BulkOperationException Uses MongoBulkWriteException and com.mongodb.bulk.BulkWriteError instead of BulkWriteException and com.mongodb.BulkWriteError
ReactiveMongoClientFactoryBean Uses com.mongodb.MongoClientSettings instead of com.mongodb.async.client.MongoClientSettings
ReactiveMongoClientSettingsFactoryBean Now produces com.mongodb.MongoClientSettings instead of com.mongodb.async.client.MongoClientSettings

Removed Java API

2.x Replacement in 3.x Comment
MongoClientOptionsFactoryBean MongoClientSettingsFactoryBean Creating a com.mongodb.MongoClientSettings.
AbstractMongoConfiguration AbstractMongoClientConfiguration (Available since 2.1) Using com.mongodb.client.MongoClient.
MongoDbFactory#getLegacyDb() - -
SimpleMongoDbFactory SimpleMongoClientDbFactory (Available since 2.1) -
MapReduceOptions#getOutputType() MapReduceOptions#getMapReduceAction() Returns MapReduceAction instead of MapReduceCommand.OutputType.
Meta|Query maxScan & snapshot - -

Changed XML Namespace Elements and Attributes:

Element / Attribute 2.x 3.x
<mongo:mongo-client /> Used to create a com.mongodb.MongoClient Now exposes a com.mongodb.client.MongoClient
<mongo:mongo-client replica-set="..." /> Was a comma delimited list of replica set members (host/port) Now defines the replica set name. Use <mongo:client-settings cluster-hosts="..." /> instead
<mongo:db-factory writeConcern="..." /> NONE, NORMAL, SAFE, FSYNC_SAFE, REPLICAS_SAFE, MAJORITY W1, W2, W3, UNAKNOWLEDGED, AKNOWLEDGED, JOURNALED, MAJORITY

Removed XML Namespace Elements and Attributes:

Element / Attribute Replacement in 3.x Comment
<mongo:db-factory mongo-ref="..." /> <mongo:db-factory mongo-client-ref="..." /> Referencing a com.mongodb.client.MongoClient.
<mongo:mongo-client credentials="..." /> <mongo:mongo-client credential="..." /> Single authentication data instead of list.
<mongo:client-options /> <mongo:client-settings /> See com.mongodb.MongoClientSettings for details.

New XML Namespace Elements and Attributes:

Element Comment
<mongo:db-factory mongo-client-ref="..." /> Replacement for <mongo:db-factory mongo-ref="..." />
<mongo:db-factory connection-string="..." /> Replacement for uri and client-uri.
<mongo:mongo-client connection-string="..." /> Replacement for uri and client-uri.
<mongo:client-settings /> Namespace element for com.mongodb.MongoClientSettings.

UUID Type Changes

The MongoDB UUID representation can now be configured with different formats.
This has to be done via MongoClientSettings as shown in the snippet below.

class Config extends AbstractMongoClientConfiguration {

    @Override
    public void configureClientSettings(MongoClientSettings.Builder builder) {
        builder.uuidRepresentation(UuidRepresentation.STANDARD);
    }

    // ...
}

Supersedes: #812

christophstrobl and others added 8 commits January 27, 2020 09:58
This change switches to the MongoDB 4.0 driver and introduces configuration options for com.mongodb.client.MongoClient.
The XML namespace changed from client-options to client-settings and removed already deprecated elements and attributes.

Imports are switched from single artifact uber jar to split imports for driver-core, -sync and -reactivestreams.
Deprecations have been removed.
Rename to follow MongoDB's naming scheme. Re-introduce deprecated MongoDbFactory to aid migration.
Replace leftovers to Mongo 2.x API with Document and MongoDatabase references and tweak Javadoc. Reorder field declarations to class header. Reflect 3.0 versions in schema configuration. Add TODO markers to disabled tests.
Reflect changes in documentation.

Enable disabled test.
…ublisher API and introduce UUID format configuration options.

Move from AsyncInputStream handling to Publisher for GridFS.
UUID types require additional configuration setup to prevent errors while processing legacy (type 3) binary types. We still use type 3 as default but allow codec configuration for type 4 via Java and XML configuration.
Updated migration guide.
Enable disabled tests. Adapt to ReactiveGridFS changes.

Use WriteConcern.MAJORITY in tests.
mp911de pushed a commit that referenced this pull request Jan 27, 2020
This change switches to the MongoDB 4.0 driver and introduces configuration options for com.mongodb.client.MongoClient.
The XML namespace changed from client-options to client-settings and removed already deprecated elements and attributes.

Imports are switched from single artifact uber jar to split imports for driver-core, -sync and -reactivestreams.
Deprecations have been removed.

Original pull request: #823.
mp911de added a commit that referenced this pull request Jan 27, 2020
Rename to follow MongoDB's naming scheme. Re-introduce deprecated MongoDbFactory to aid migration.

Original pull request: #823.
mp911de added a commit that referenced this pull request Jan 27, 2020
Replace leftovers to Mongo 2.x API with Document and MongoDatabase references and tweak Javadoc. Reorder field declarations to class header. Reflect 3.0 versions in schema configuration. Add TODO markers to disabled tests.
Reflect changes in documentation.

Enable disabled test.

Original pull request: #823.
mp911de pushed a commit that referenced this pull request Jan 27, 2020
…ublisher API and introduce UUID format configuration options.

Move from AsyncInputStream handling to Publisher for GridFS.
UUID types require additional configuration setup to prevent errors while processing legacy (type 3) binary types. We still use type 3 as default but allow codec configuration for type 4 via Java and XML configuration.
Updated migration guide.

Original pull request: #823.
mp911de added a commit that referenced this pull request Jan 27, 2020
Enable disabled tests. Adapt to ReactiveGridFS changes.

Use WriteConcern.MAJORITY in tests.

Original pull request: #823.
mp911de added a commit that referenced this pull request Jan 27, 2020
Guard tests.

Original pull request: #823.
mp911de added a commit that referenced this pull request Jan 27, 2020
@mp911de
Copy link
Member

mp911de commented Jan 27, 2020

That's merged and polished now.

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

Successfully merging this pull request may close these issues.

None yet

2 participants