How-To Guides
Integration Guides

MongoDB Integration Guide

11min

Review the following guide for setting up an integration between Litmus 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.

Video



User Scenario

In this guide you will deploy a MongoDB database container from Litmus 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+).

Step 1: Add Device



Step 2: Add Tags



Step 3: Add MongoDB Marketplace Application

Note: The version used in this guide for MongoDB is 4.4.4.

To add the MongoDB Marketplace Application:

  1. In Litmus Edge, navigate to Applications > Marketplace.
  2. Click Marketplace List and select Default Marketplace Catalog.
  3. Click the MongoDB application tile.
  4. From the Installation script version drop-down list, select latest.
  5. Enter MongoDB in the Name field.
  6. Click Launch.
  7. Navigate to Applications > Catalog Apps. The MongoDB application appears, pulls the image, and then starts the application. The MongoDB application shows as running.
  8. Navigate to Applications > Containers. 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 and select the DB - MongoDB provider.

Configure the following parameters.

  • Name: Enter a name for 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: If you want to send data to a custom table, select this check box and unselect Create table. See Work with Tables in SQL Connectors (Create Table and Show Mapping) to learn more. To 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 Litmus 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.

Step 5: Enable the Connector

After adding the connector, click the toggle in the connector tile to enable it.

Document image


If you see a Failed status, you can review the Connector Logs and relevant error messages.

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.



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

Step 7: Enable Topics



Step 8: Make MongoDB Queries

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 queries in the MongoDB container terminal:

  1. In Litmus Edge, navigate to Applications > Containers.
  2. Click the Terminal icon 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 appears and connects.
  4. Enter show databases and press ENTER. The db-sample database name appears in the console.
  5. Enter use db-sample and press ENTER. The directory switches to db-sample.
  6. Enter show collections and press ENTER. The devicehub collection list appears.
  7. Enter db.devicehub.find() and press ENTER. Confirm you see data being loaded into the collection.
Document image