Contact Free trial Login

MongoDB Connector 4.0.2 Migration Guide

The MongoDB connector v4.0.2 is a completely revamped connector and is not compatible with any of its older versions.

Connector Guide: MongoDB Connector

MongoDB Version 4.0.2 Versus Previous Versions

MongoDB Connector 4.0.2 Previous versions

Global Configuration

  • Configuration: This configuration requires the following credentials: username, password, database, and host. Remember that we no longer support the port field. Now you will have to provide "host:port" inside the host field of your mongo:config element.

  • Advance: Apart from what is available in the above configuration, you can now set a list of comma-separeted servers in your host field.

In the previous version of the connector, you require the following credentials: username, password, database, host and port.

Mongo DataTypes

  • Write Concern and Write Result do not exist anymore.

  • No Write Concern to be set and your operations will only return Strings, Documents and DBObjects.

  • In the previous version of the connector, you had to set the Write Concern parameter.

  • Some operations return a Write Result object with the status of the operation.

Payload Manipulation

Use of Dataweave is encouraged to manipulate the payload for input and to process the response. The connector picks the input request from the flow payload, and it only accepts payloads of JSON type.

Previous versions of the connector enable the user to create the request using the DataMapper, the Java Component, or the Groovy Component.

New operation names

  • With the driver update, we also updated the operation names to suit driver changes.

Mongo 3.0

Mongo 4.0

Count objects

Count documents

End consistent request

This operation has been deleted

Find one object

Find one document

Insert object

Insert document

Remove object

Remove document

Save object

Save document

Start consistent request

This operation has been deleted

Update objects

Update documents

Update objects by function

Update documents by function

"XX using query map"

All this operations have been deleted. You will now have to use Data Weave to create a query

Updating From an Older Version

  • Uninstall the previous MongoDB Connector.

  • Install the latest version of the MongoDB Connector from the update site.

  • Ensure that the Maven dependencies have been updated correctly from Mongo DB[v3.X.X] to Mongo DB[v4.0.2].

  • Update flows that are using Phased Out or Deprecated operations.

    • Most operation names have been changed to comply with Mongo Driver v3, so if you had an InsertObject operation, now it will appear as InsertDocument.

    • WriteResult objects have been removed. Now your operations will only return Strings, Documents and DBObjects.

    • MongoDB transformers have been replaced by implicit ones. So, if your input data is a Map and, you want to perform an Insert operation, just drag a MongoDB connector into the workspace, choose the InsertDocument operation and you’re done! You no longer require the use of the transformer.

    • Remember that mongo:config does NOT support the port field anymore. Now you will have to specify the port inside the host field of your mongo:config using the format "host:port". For more information see the MongoDB Connector 4.0.2 Migration Guide

Post Installation

The following sections describe how to complete an installation from either Maven or non-Maven projects.

Maven Based Project

  1. Open the project’s pom.xml file and delete any references to the older version. The artifact-id of the previous versions follow the following format mule-module-mongo

  2. Add the MongoDB connector reference by setting the version property to 4.0.2

  3. Save your pom.xml file changes.

The user may need to manually update the project dependencies.

Non-Maven Based Project

  • Locate the MongoDB connector library, right-click the library, and click Build Path > Remove from Build Path.

  • To import the MongoDB connector v4.0.2 library, right-click the project, click Build Path > Add Libraries > Anypoint Connectors Dependencies, and locate Mongo DB v4.0.2.

After following the steps above, update your flows by replacing the MongoDB Connector with the newer version and its data mappings.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.