MongoDB Integration Guide
Review the following guide for setting up an integration between Manufacturing Connect Edge and a MongoDB database.
For this integration, you can use either the DB-MongoDB or DB-MongoDB v4+ connector.
See the the MongoDB documentation for more information.
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.
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+).
Note: The version used in this use case for MongoDB is 4.2.
To add the MySQL Marketplace Application:
- In Manufacturing Connect Edge, navigate to Applications > Marketplace.
- Click Marketplace List and select Default Marketplace Catalog.
- Click the MongoDB application tile.
- From the Installation script version drop-down list, select latest.
- Enter MongoDB in the Name field.
- Click Launch.
- Navigate to Applications > Catalog Apps. The MongoDB application appears, pulls the image, and then starts the application. The MongoDB application shows as running.
- Navigate to Applications > Containers. The MongoDB application Container is running.
- Copy the IP address for the MongoDB application.
Follow the steps to Add a Connector and select the DB - MongoDB provider.
Configure the following parameters.
- Name: A recognizable name to identify the connector.
- Hostname: Paste the IP address you copied in Step 3.
- Port: The MongoDB Server port. The default value is 27017.
- Username(Optional): Leave the field blank.
- Password (Optional): Leave the field blank.
- Auth database (Optional): The authentication database name. The default value is admin.
- Auth mechanism: Select PLAIN.
- Database: Enter db-sample.
- Collection: Enter devicehub.
- Show Mapping: Select the check box to display mappings. See Work with Tables in SQL Connectors (Create Table and Show Mapping) to learn more. Too add key/value pairs for the custom table, see Configure Key/Value Pairs.
- 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.
- 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.
- Queue Mode: Select the queue mode as lifo (last in first out) or fifo (first in first out). Selecting lifo means that the last data entry is processed first, and selecting fifo means the first data entry is processed first.
After adding the connector, click the toggle in the connector tile to enable it.
If you see a Failed status, you can review the Connector Logs and relevant error messages.
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.
After adding all required topics, navigate to the Integration overview page and ensure the connector is not disabled and still shows a CONNECTED status.
You can now verify that you can view data through the terminal command window.
Update the database and collection names to your own specific configurations.
To make MongoDB queries:
- In Manufacturing Connect Edge, navigate to Applications > Containers.
- Click the Terminal icon next to the MongoDB container. The MongoDB shell opens.
- From the MongoDB container terminal, enter mongo and press ENTER. The MongoDB shell version v4.4.4 appears and connects.
- Enter show databases and press ENTER. The db-sample database name appears in the console.
- Enter use db-sample and press ENTER. The directory switches to db-sample.
- Enter show collections and press ENTER. The collection list appears.
- Enter db.devicehub.find() and press ENTER. Confirm you see data being loaded into the collection.