App Connect

App Connect

Join this online user group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#Applicationintegration
#App Connect
#AppConnect
#Integration
#Automation
 View Only

Retrieve user data from MongoDB users collection using the Loopback Request Node in IBM App Connect Enterprise.

By P VENKATA SUBBA REDDY posted 06/29/26 01:05 PM

  

This guide demonstrates connecting IBM App Connect Enterprise (ACE) v13.0.7.0 to MongoDB using the Loopback Request Node 

The setup involves four main phases:

  1. MongoDB setup
  2. Security Configuration
  3. Loopback Datasource & Model Setup
  4. Message Flow Creation

1. MongoDB 8.0 Installation and Configuration Guide

Installation

# Download MongoDB Server
[root@pvsdb1 ~]# wget https://repo.mongodb.org/yum/redhat/8/mongodb-org/8.0/x86_64/RPMS/mongodb-org-server-8.0.6-1.el8.x86_64.rpm


# Set Permissions
[root@pvsdb1 ~]# chmod 777 mongodb-org-server-8.0.6-1.el8.x86_64.rpm 

# Install Package

[root@pvsdb1 ~]# yum install mongodb-org-server-8.0.6-1.el8.x86_64.rpm


# Check status
systemctl status mongod.service

Configuration

# Enable Remote Access
Edit /etc/mongod.conf:
net:
  port: 27017
  bindIp: 0.0.0.0  # Allows connections from any IP

# Restart after configuration changes
systemctl restart mongod.service

Database Setup

# Connect to MongoDB

[root@pvsdb1 ~]# mongosh "mongodb://x.x.x.x:27017"

# Switch to database
test> use customerdb

# Create user with readWrite permissions
customerdb> db.createUser({
|   user: "mongodbuser",
|   pwd: "Passw0rd123",
|   roles: [
|     { role: "readWrite", db: "customerdb" }
|   ]
| })
{ ok: 1 }

# Verify user creation
customerdb> db.getUsers()

# Enable Authentication
Add to /etc/mongod.conf:
security:
  authorization: enabled

# Restart after configuration changes
systemctl restart mongod.service

# Check status

[root@pvsdb1 ~]# systemctl status mongod.service 

# Connect with Authentication

[root@pvsdb1 ~]# mongosh "mongodb://mongodbuser:Passw0rd123@x.x.x.x:27017/customerdb?authSource=customerdb"

Operations

# Insert Documents
customerdb> db.users.insert({name: "user01”, age: 25}))
customerdb> db.users.insert({name: "user02", age: 26})

# Retrieve all with limit
customerdb>  db.users.find().limit(10)

Results:

[
  { _id: ObjectId('6a3f594e7ab92e75c365dce2'), name: 'user01', age: 25 },
  { _id: ObjectId('6a3f5bde7ab92e75c365dce3'), name: 'user02', age: 26 }
]

2. Security Identity Configuration

# Create MongoDB DSN

[root@pvsredd1 ~]# mqsisetdbparms <NODE> -n loopback::MONGODBDSN -u mongodbuser -p Passw0rd123

Parameters:
* <NODE>: Your ACE integration node name
* -n loopback::MONGODBDSN: Security identity name for MongoDB
* -u mongodbuser: MongoDB username
* -p Passw0rd123: MongoDB password

NOTE: Restart the broker to reflect the changes

3.Loopback Configuration

# Source the mqsiprofile
[root@pvsreddy1 ~]# source <MQSI_BASE_FILEPATH>/server/bin/mqsiprofile

# Install the loopback connector mongodb

[root@pvsreddy1 /]# cd <MQSI_WORKPATH>

Note:

MQSI_WORKPATH = /var/mqsi

MQSI_BASE_FILEPATH = /home/pvsreddy/ace-13.0.7.0

#Run npm install

[root@pvsreddy1 mqsi]# npm install loopback-connector-mongodb

#Verify loopback connector mongodb under below path 

<MQSI_WORKPATH>/node_modules/

# Directory Structure
<MQSI_WORKPATH>/connectors/loopback/
└── datasources.json
└── mongodb_dev/
    └── users.json

# Create datasources.json

This file defines the MongoDB connection parameters:

{
   "mongodb_dev": {
      "name": "mongodb_dev",
      "connector": "mongodb",
      "host": "x.x.x.x",
      "port": 27017,
      "database": "customerdb",
      "username": "mongodbuser",
      "password": "Passw0rd123"
   }
}

Configuration Details:
* name: Datasource identifier
* connector: Must be "mongodb" for MongoDB connections
* host: MongoDB server IP address
* port: MongoDB port (default: 27017)
* database: Target database name
* username/password: MongoDB credentials

# Create the datasource directory
Example:

 cd <MQSI_WORKPATH>/connectors/loopback
   mkdir mongodb_dev

# Create Model file users.json

This defines the data model mapping to MongoDB collection:

{
  "name": "users",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "mongodb": {
      "collection": "users"
    }
  },
  "properties": {
    "name": {
      "type": "string",
      "required": true
    },
    "age": {
      "type": "number",
      "required": true
    }
  }
}

Model Components:
* name: Model identifier
* base: Extends PersistedModel for CRUD operations
* idInjection: Auto-generates ID field
* options.mongodb.collection: Maps to MongoDB collection name
* properties: Defines schema fields with types and validation

4. Message Flow Creation

# The flow consists of three nodes that work together to fetch and return MongoDB data:

1. HTTP Input Node

* Path: /loopback/getUsers
* Function: Receives incoming HTTP GET requests

2. Loopback Request Node
* Datasource: mongodb_dev
* Model: users
* Operation: find() - retrieves all documents from users collection
* Function: Executes MongoDB query through Loopback connector

3. HTTP Reply Node

Save, deploy and execute the flow:

Results:

0 comments
22 views

Permalink