Contact Free trial Login

MongoDB Studio Configuration - Mule 4

To configure a connector in Anypoint Studio follow this process:

  1. Install the connector.

  2. Configure the connector.

  3. Configure an input source for the connector.

Install the Connector Using Exchange

  1. In Studio, create a Mule project.

  2. Click the Exchange (X) icon in the upper left of the Studio task bar.

  3. In Exchange, click Login and supply your Anypoint Platform username and password.

  4. In Exchange, search for "MongoDB".

  5. Select the MongoDB Connector and click Add to project.

  6. Follow the prompts to install the connector.

Install the Connector in Studio

  1. In Studio, create a Mule project.

  2. In the Mule Palette, click (X) Search in Exchange.

  3. In Add Modules to Project, type the name of the connector in the search field.

  4. Click the MongoDB Connector name in Available modules.

  5. Click Add.

  6. Click Finish.

Configure the Connector

  1. On the Global Element tab, click Create.

  2. Search for MongoDB from the Connector Configuration directory.

  3. When you select a global element, you are presented with the global element properties to enter.

  4. Select the type of Connection.

  5. The Username field refers to the username you use to access your MongoDB instance.

  6. The Password field should contain the corresponding password.

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

  8. You may also need to set the Servers property which is composed of a host:port comma-separated list (in case you have a replica set). This attribute is optional, and if left empty, it defaults to localhost:27017.

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

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

This location points to the default MongoDB instance.

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.

Global Configuration with SSL (Optional)

MongoDB Connector v4.0.0 and later supports the use of SSL. To set up the Global Configuration:

  • In the Global Element tab for your MongoDB connection, select the true SSL property field in the Connection tab.

  • Your instance must support this feature.

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.

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.