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:
-
Access the API Explorer: Open a web browser and go to
[HOST]:8080/api-explorer/
to access the API Explorer. -
Navigate to the Database Tag: Locate and click on the
database
tag within the API Explorer to view various database configuration and operation endpoints. -
Configure Connection Pool: Use the
esbapi/databases
endpoint found under the database tag to save a database connection pool. -
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 11 12 13 14 15 16 17 18 19 20
{ "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]", "connectionPoolSettings": { "maintenanceFrequency": 60000, "maintenanceInitialDelay": 0, "maxConnectionIdleTime": 0, "maxConnectionLifeTime": 0, "maxWaitTime": 120000, "maxWaitQueueSize": 500, "minSize": 0, "maxSize": 100 } }
Via File System:
Alternatively, database connections can be modified directly in the file system by editing the <name>.dbxml
file located in the /<martini-home>/conf/db-pool/
directory. The <name>.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:
-
Locate the Configuration File: Navigate to the
/<martini-home>/conf/db-pool/
directory on your server and locate the<name>.dbxml
file. -
Edit the Database Connections: Open the
<name>.dbxml
file in a text editor and modify the database connection properties. -
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 the updated minimum requirement for a dbXML:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Configuring MongoDB in Martini Designer
- Navigate to the Navigator view and right-click on the Databases node of the instance where you intend to add the database connection.
- Choose New > Database Connection.
- Specify a name for the connection and select the database type MongoDB.
- Fill in the database connection details in the provided form.
- 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. |