This location points to the default MongoDB instance.
MongoDB Studio Configuration - Mule 4
To configure a connector in Anypoint Studio follow this process:
-
Install the connector.
-
Configure the connector.
-
Configure an input source for the connector.
Install the Connector Using Exchange
-
In Studio, create a Mule project.
-
Click the Exchange (X) icon in the upper left of the Studio task bar.
-
In Exchange, click Login and supply your Anypoint Platform username and password.
-
In Exchange, search for "MongoDB".
-
Select the MongoDB Connector and click Add to project.
-
Follow the prompts to install the connector.
Install the Connector in Studio
-
In Studio, create a Mule project.
-
In the Mule Palette, click (X) Search in Exchange.
-
In Add Modules to Project, type the name of the connector in the search field.
-
Click the MongoDB Connector name in Available modules.
-
Click Add.
-
Click Finish.
Configure the Connector
-
On the Global Element tab, click Create.
-
Search for MongoDB from the Connector Configuration directory.
-
When you select a global element, you are presented with the global element properties to enter.
-
Select the type of Connection.
-
The Username field refers to the username you use to access your MongoDB instance.
-
The Password field should contain the corresponding password.
-
Specify the Database that sends and retrieves data from your MongoDB instance. Before running your application, make sure you have the necessary permissions to do so.
-
You may also need to set the Servers property which is composed of a
host:portcomma-separated list (in case you have a replica set). This attribute is optional, and if left empty, it defaults tolocalhost:27017. -
In the Connection tab, you may adjust the values for the Connect Timeout, Connections Per Host, Max Wait Time and the Socket Timeout for requests that are sent to MongoDB. The default value for Connect Timeout is 30000 milliseconds. Any connection requests that take longer than 30 seconds to be sent and received throw an exception. You can override this behavior by setting their values to 0, meaning that the MongoDB connector waits indefinitely until a request is successfully sent and a response is received.
-
You may choose to enable metadata and add a collection sample.
The MongoDB configuration with Spring property placeholders for the Connection field values is the recommended approach when you plan to deploy your application to CloudHub or to a Mule runtime.
However, you may hard code your connection credentials in the Global Element Properties if you are in the development stage and want to speed up the process.
| Fields | Description |
|---|---|
Servers |
|
Username |
MongoDB username. |
Password |
MongoDB password. |
Database |
MongoDB database. |
Enable Metadata |
Enables metadata for collections, documents and files. |
Collection metadata samples |
Allows you to add existing collections to take metadata structure from. |
Configure an Input Source
Configure an input source for the connector such as a connector operation, using an HTTP Listener, or Scheduler.
You can use the following operations for the connector in the Source area of the Studio canvas.
-
Deleted Object
-
Modified Object
-
New Object
These operations invoke your application when MongoDB has a new, deleted, or modified object.
Next
After configuring Studio, see the Examples topic for more configuration ideas.



