Connecting to MongoDB server from SAP Cloud Platform Integration using Camel MongoDB component
This blog is a continuation series of the our earlier blog https://blogs.sap.com/2020/07/16/apache-camel-community-adapters-usage-in-sap-cloud-platform-integration/ , which talks about usage of Apache Camel Components as SAP Cloud Platform integration ADK compliant integration adapters in the integration flow.
In this series let us understand how to use the Apache camel MongoDB component as the SAP cloud platform integration adapter.
You can find the adapter artifacts in the SAP GitHub apibusinesshub-integration-recipes, whose link is provided below
In the Apache Camel MongoDB component, it looks for a bean to resolve the MongoDB server details, here in the code that bean lookup is bypassed with the manual server configuration, which you have to provide in the project source.
Please import the project source in to Eclipse IDE using Maven project import wizard and edit the MongoDbComponent.java class ,CreateEndpoint method and provide the mongoDB server configuration as shown below:
after doing the changes, build the project using “maven clean install” and generate the adapter ESA file. which you have to deploy in to the CPI integration runtime
Deploy the Integration adapter ESA file on to the SAP cloud platform integration runtime
After successful deployment you can see the adapter under the deployed artifacts
As a next step You can import the integration flow, which is provided as a part of artifacts, which demonstrate the usage of the Apache Camel MongoDB component.
After importing the MongoDB integration flow, you can provide MongoDB server configuration
you can see an example configuration shown in the adapter property sheet
After providing all the configuration, save/deploy the integration flow and check that the integration flow message processing successfully completed in the CPI monitoring.
Input provided in the Integration Flow for storing the message payload into the MongoDB database
You can connect to MongoDB database server from any of standard Clients and check the message persisted from SAP Cloud Platform Integration flow message processing
You can also use the Apache Camel MongoDB component project source provided as a part of artifact samples, modify it as per your requirements by importing the project in to Eclipse IDE using Maven project import wizard.
Do your changes as required, build the final project using Maven build, which will generate the ESA file, which is the Cloud integration ADK compliant adapter.
Also going forward, we continue to provide more samples of Apache Camel components (https://github.com/apache/camel/tree/master/components ) as Cloud integration ADK Compliant adapters. Here all the components we provide based on Apache Camel version 2.17.4.
Disclaimer: This adapter is shipped as “community contribution” under Apache 2.0 license; support for this adapter should be requested by raising an issue in the GitHub repo and not standard SAP channels.
Great article, so by default natively CPI can be integrated with mongoDB? or the only way is to use the apache camel connectors?
First question :
That mean that the connection to the Mongodb database is hard coded in the adapter ?
So, if I have 3 databases dev, test Prod, I need 3 adapters.
Second question :
My database need a user and password.
So I have to to use something like that :
Is it correct ? that mean that my user/password are also hard coded. Is there a security risk there ?
Third question :
My database is on premise. So, I guess I need to use the cloud connector. how do it interface with the adapter ?