Skip to content

MongoDB

MongoDB with Martini Runtime combines MongoDB's flexible NoSQL data model with Martini's powerful API and microservices framework. This integration enables seamless CRUD operations, workflows, and data interactions, all within a low-code environment.

By leveraging Martini Runtime's support for various protocols, developers can easily integrate MongoDB with other services, making it ideal for building scalable, event-driven applications. This setup provides a streamlined solution for managing microservices, APIs, and distributed data storage.

Configuring MongoDB

Configuring MongoDB with Martini Runtime involves setting up Martini's MongoDB connector, allowing seamless integration for CRUD operations and data management. Developers can define MongoDB connections within Martini, enabling the creation of services and workflows that interact directly with MongoDB collections. Martini Runtime simplifies the process with its low-code interface, allowing rapid development and deployment of MongoDB-powered applications. Here are different ways on adding a new database connection:

Configuration Guide

Via API Explorer: Database connections can be configured using the Martini API Explorer, a user-friendly interface designed for efficient interaction with the system's APIs. Follow these steps to configure the database connections through the API Explorer:

  1. Access the API Explorer: Open a web browser and go to [HOST]:8080/api-explorer/ to access the API Explorer.

  2. Navigate to the Database Tag: Locate and click on the database tag within the API Explorer to view various database configuration and operation endpoints.

  3. Configure Connection Pool: Use the esbapi/databases endpoint found under the database tag to save a database connection pool.

  4. Use POST to Save a Connection Pool: Save the connection pool by using the POST method at the /esbapi/databases endpoint. Here is a minimum requirement for a JSON payload:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
     {
      "name": "[name]",  
      "type": "mongodb",
      // The connection string for connecting to the MongoDB server. Replace [HOST] with the MongoDB server address and [PORT] with the port number.
      "connectionString": "mongodb://[HOST]:[PORT]", 
      // The username for authentication. Replace [username] with your MongoDB username. 
      "username": "[username]",
      // The password for authentication. Replace [password] with your MongoDB password.
      "password": "[password]" 
     }
    

Via File System: Alternatively, database connections can be modified directly in the file system by editing the .dbxml file located in the //conf/db-pool/ directory. The .dbxml file refers to the specific file for your database configuration. This method is particularly useful in environments with restricted API access or during initial setup stages.

To modify database connections directly through the file system, follow these steps:

  1. Locate the Configuration File: Navigate to the /<martini-home>/conf/db-pool/ directory on your server and locate the <name>.dbxml file.

  2. Edit the Database Connections: Open the <name>.dbxml file in a text editor and modify the database connection properties.

  3. Save and Restart: After making the desired changes, save the file. It is essential to restart the Martini Runtime instance to apply the new settings. This ensures that all components of the application use the updated MongoDB configuration. Here is a minimum requirement for a dbXML:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    <database>
      <name>[name]</name>
      <type>mongodb</type> 
      <!-- The connection string for connecting to the MongoDB server. Replace [HOST] with the MongoDB server address and [PORT] with the port number. -->
      <connectionString>>mongodb://[HOST]:[PORT]</connectionString> 
      <!-- The username for authentication. Replace [username] with your MongoDB username. --> 
      <username>[username]</username> 
      <!-- The password for authentication. Replace [password] with your MongoDB password. -->
      <password>[password]</password>
    <database>
    

Configuring MongoDB in Martini Designer

  1. Navigate to the Navigator view and right-click on the Databases node of the instance where you intend to add the database connection.
  2. Choose New > Database Connection.
  3. Specify a name for the connection and select the database type MongoDB.
  4. Fill in the database connection details in the provided form.
  5. Save the changes.

Database Properties

The table below outlines the configurable properties for a database connection:

Field Name Parameters Required Default Value Description
Name name true null The name of the database connection.
Type type true null The type of database (e.g., mongodb).
Connection String connectionString true null The connection string for connecting to the MongoDB server.
Username username true null The username for MongoDB server authentication.
Password password false (empty) Password for MongoDB server authentication.
Authentication Mechanism authenticationMechanism false AUTO Authentication mechanism to use when connecting to MongoDB.
Local Threshold localThreshold false 15 The local threshold in milliseconds for the cluster settings.
Server Selection Timeout serverSelectionTimeout false 30000 Timeout in milliseconds for selecting a MongoDB server.
Cluster Type type false UNKNOWN The type of cluster being used.
Maintenance Frequency maintenanceFrequency false 60000 Frequency in milliseconds for performing connection pool maintenance.
Maintenance Initial Delay maintenanceInitialDelay false 0 Initial delay in milliseconds before starting connection pool maintenance.
Minimum Pool Size minSize false 0 Minimum size of the connection pool.
Maximum Connection Idle Time maxConnectionIdleTime false 0 Maximum idle time in milliseconds for a connection in the pool.
Maximum Connection Life Time maxConnectionLifeTime false 0 Maximum life time in milliseconds for a connection in the pool.
Maximum Wait Time maxWaitTime false 120000 Maximum time in milliseconds to wait for a connection to become available.
Maximum Pool Size maxSize false 100 Maximum number of connections in the pool.
Heartbeat Frequency heartbeatFrequency false 10000 Frequency in milliseconds for sending heartbeat messages to the MongoDB server.
Minimum Heartbeat Frequency minHeartbeatFrequency false 500 Minimum frequency in milliseconds for sending heartbeat messages.
Connection Timeout connectTimeout false 10000 Timeout in milliseconds for connecting to the MongoDB server.
Read Timeout readTimeout false 0 Timeout in milliseconds for reading data from the MongoDB server.
Receive Buffer Size receiveBufferSize false 0 Size in bytes of the receive buffer for socket connections.
Send Buffer Size sendBufferSize false 0 Size in bytes of the send buffer for socket connections.