---
title: MongoDB Integration Guide
slug: manufacturing-connect-edge/mongodb-integration-guide
docTags: 
createdAt: 2022-11-24T18:29:19.000Z
---

Review the following guide for setting up an integration between Manufacturing Connect Edge and a MongoDB database.&#x20;

For this integration, you can use either the DB-MongoDB or DB-MongoDB v4+ connector.&#x20;

See the the [MongoDB documentation](https://www.mongodb.com/docs/) for more information.&#x20;

# User Scenario

In this guide you will deploy a MongoDB database container from Manufacturing Connect Edge and then integrate with the database using the DB-MongoDB connector. For your specific scenario you may use an external MongoDB database to set up the integration.&#x20;

If you do use an external MongoDB database, make sure to use the appropriate connector depending on the version of MongoDB you are using (DB-MongoDB or DB-MongoDB v4+).&#x20;

# Step 1: Add Device

Follow the steps to [Connect a Device](docId\:RFVIJdxz7DBAd8mwbismA). The device will be used to store tags that will be eventually used to create outbound topics in the connector. Make sure to select the **Enable Data Store** checkbox.&#x20;

# Step 2: Add Tags

After connecting the device in Manufacturing Connect Edge, you can [Add Tags](docId\:iOaNZd2AwqnkuppgeE3Eh) to the device. Create tags that you want to use to create outbound topics for the connector.&#x20;

# Step 3: Add MySQL Marketplace Application

:::hint{type="info"}
**Note**: The version used in this use case for MongoDB is 4.2.
:::

**To add the MySQL Marketplace Application:**

1. In Manufacturing Connect Edge, navigate to **Applications&#x20;**> **Marketplace**.
2. Click **Marketplace List** and select **Default Marketplace Catalog**.
3. Click the **MongoDB** application tile.&#x20;
4. From the **Installation script version** drop-down list, select **latest**.&#x20;
5. Enter **MongoDB&#x20;**&#x69;n the **Name&#x20;**&#x66;ield. &#x20;
6. Click **Launch**.&#x20;
7. Navigate to **Applications&#x20;**> **Catalog Apps**.&#x20;
   The MongoDB application appears, pulls the image, and then starts the application. The MongoDB application shows as running.
8. Navigate to **Applications&#x20;**> **Containers**.&#x20;
   The MongoDB application Container is running.
9. Copy the IP address for the MongoDB application.

# Step 4: Add the DB - MongoDB Connector

Follow the steps to [Add a Connector](docId\:M2niFNAAdyPHcvZWMCOTo) and select the **DB - MongoDB&#x20;**&#x70;rovider.&#x20;

Configure the following parameters.&#x20;

- **Name**: A recognizable name to identify the connector.&#x20;
- **Hostname**: Paste the IP address you copied in Step 3. &#x20;
- **Port**: The MongoDB Server port. The default value is **27017**.&#x20;
- **Username**(Optional): Leave the field blank.&#x20;
- **Password&#x20;**(Optional): Leave the field blank.&#x20;
- **Auth database** (Optional): The authentication database name. The default value is **admin**.&#x20;
- **Auth mechanism**: Select **PLAIN**.&#x20;
- **Database**: Enter **db-sample**.&#x20;
- **Collection**: Enter **devicehub**.&#x20;
- **Show Mapping**: Select the check box to display mappings. See [Work with Tables in SQL Connectors (Create Table and Show Mapping)](docId\:FI9mBipRrRIxufdIHwQl9) to learn more. Too add key/value pairs for the custom table, see [Configure Key/Value Pairs](docId\:FI9mBipRrRIxufdIHwQl9).&#x20;
- **Commit timeout**: Enter the transaction commit timeout in (ms).
- **Max transaction size**: Enter the maximum number of messages before a transaction is committed, regardless of timeout parameter.
- **Throttling limit**: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.&#x20;
- **Persistent storage**: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Manufacturing Connect Edge when cloud providers are online. &#x20;
- **Queue Mode**: Select the queue mode as **lifo&#x20;**(last in first out) or **fifo&#x20;**(first in first out). Selecting **lifo&#x20;**&#x6D;eans that the last data entry is processed first, and selecting **fifo&#x20;**&#x6D;eans the first data entry is processed first.&#x20;

# Step 5: Enable the Connector

After adding the connector, click the toggle in the connector tile to enable it.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/16EGMNlH0uu0crIFIiCer_kafkatcp.png" size="60" width="411" height="343" position="center" showCaption="false"}

If you see a *Failed&#x20;*&#x73;tatus, you can review the [Connector Logs](docId\:Zz28hZtQBK7oD_Xsj81O8) and relevant error messages.&#x20;

# Step 6: Create Topics for Connector

You will now need to import the tags created in Step 2 as topics for the MongoDB connector. The topics will be created as outbound topics.

**To create outbound topics:**

1. Click the connector tile.
   The connector *Dashboard&#x20;*&#x61;ppears.&#x20;
2. Click the **Topics&#x20;**&#x74;ab.&#x20;
3. Click the **Import from DeviceHub tags** icon.&#x20;
   The *DeviceHub Import* dialog box appears.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/QUo-NUFfBj7F2BbnlBBj3_importdevicehub.png" size="80" width="1218" height="567" caption="Import from DeviceHub icon" position="center" showCaption="true"}
4. Select all the tags to import and click **Import**.&#x20;

After adding all required topics, navigate to the Integration overview page and ensure the connector is not disabled and still shows a CONNECTED status.&#x20;

# Step 7: Enable Topics

To enable the topics, return to the *Topics&#x20;*&#x74;ab and click the **Enable all topics** icon.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/_r9Zt0i2zdoHv9dd9d5xx_image.png" size="80" width="1218" height="567" caption="Enable all topics icon" position="center" showCaption="true"}

# Step 8: Make MongoDB Queries

You can now verify that you can view data through the terminal command window.&#x20;

Update the database and collection names to your own specific configurations.&#x20;

**To make MongoDB queries:**

1. In Manufacturing Connect Edge, navigate to **Applications&#x20;**>**&#x20;Containers**.
2. Click the **Terminal&#xA0;**&#x69;con next to the MongoDB container.
   The MongoDB shell opens.
3. From the MongoDB container terminal, enter `mongo` and press **ENTER**.
   The *MongoDB shell version v4.4.4&#xA0;*&#x61;ppears and connects.
4. Enter `show databases` and press **ENTER**.
   The *db-sample***&#xA0;**&#x64;atabase name appears in the console.
5. Enter `use db-sample`**&#xA0;**&#x61;nd press **ENTER**.
   The directory switches to *db-sample*.
6. Enter `show collections`**&#xA0;**&#x61;nd press **ENTER**.
   The collection list appears.
7. Enter `db.devicehub.find()` and press **ENTER**.
   Confirm you see data being loaded into the collection.&#x20;

