Contact Us 1-800-596-4880

MongoDB Connector 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 Overview

MongoDB Version 4.x Versus Previous Versions

MongoDB Connector 4.x 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 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-separated servers in your host field.

The previous version of the connector requires the following credentials: username, password, database, host, and port.

Mongo DataTypes

  • Write Concern and Write Result do not exist anymore.

  • No Write Concern can be set and your operations 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

New Operation Names

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

Mongo 3.x Operation Mongo 4.x Operation

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 these operations have been deleted. You now use DataWeave to create a query.

Updating From an Older Version

  1. Uninstall the previous MongoDB Connector.

  2. In Anypoint Studio, click Help > Install New Software. In the Works with drop-down menu, click Anypoint Connectors Update Site.

  3. Expand the Select category and click Mongo DB Connector version 4.x (x is the latest version number).

  4. Ensure that the Maven dependencies have been updated correctly from Mongo DB[v3.X.X] to Mongo DB[v4.0.2] (or the latest version).

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

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

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

    3. 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.

    4. Remember that mongo:config does NOT support the port field anymore. Now you have to specify the port inside the host field of your mongo:config using the format "host:port".

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 this format: mule-module-mongo

  2. Add the MongoDB connector reference by setting the version property to 4.0.2 (or the latest version).

  3. Save your pom.xml file changes.

You 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.

View on GitHub