Monday, 24 October 2016

Integrating IIB 10.0.0.6 with Mongo DB



Integrating IIB 10 with Mongo DB

            Pre-requisites:

1.       Create a free account in Mongo labs
a.       Create a free account in Mongo labs, a Cloud based Mongo DB. Obviously free of cost and you get 500 MB space
b.      Create a Collection (Table in RDBMS)

Broker Configs:

1.       Check your Environment variable MQSI_WORKPATH and switch your work path to MQSI_WORKPATH

2.      Change directory to node_modules

3.      Run the command as below to install the mongodb connector. This might take up to a minute to complete

npm install loopback-connector-mongodb --save

4.      Now a config file datasources.json has to be created. So, switch directory to MQSI_WORKPATH\ connectors\loopback. Create a file with name datasources.json and copy the below contents to the file

{
  "MONGO": {
    "host": "ds031257.mlab.com",
    "port": "31257",
    "database": "esbdev",
    "name": "MONGO",
    "connector": "mongodb",
    "debug": "true"
  }
}

5.      Configure the username and password of mongodb at the broker level using the below command

mqsisetdbparms <Broker name> -n loopback::<securityid> -n username -p password

6.      Restart your broker

7.       Create a simple message flow with http input and reply nodes (it is just my preference) and connect them to a LoopbackRequest node. Please select the input message parsing domain as “JSON”

      

8.      Configure LBR node as below. Leave the other options as default


9.      You are good to go .. deploy the flow .. If it gets successfully deployed, half done ..

10.   Post a Json message and verify the Collection to find the data you sent stored as Key-value pairs (no need of defining any schema as MongoDB is NoSQL). Sample data is given below

 

That's it :-)

No comments:

Post a Comment