Defining various DB & Salesforce access information in Mule Anypoint Studio

假如想象 提交于 2019-12-12 04:08:43

问题


I am running Mule Anypoint studio v6.2.4 under Windows. I have an application which gets data records from a SQL Server DB and populates them into Salesforce Org. The application was developed using examples and works fine in the current scenario of one DB and one SF parameters defined in mule.{mule.env}.properties file.

Now I need to access a different DB for input records and populate them to a different Salesforce org. Changing the access parameters in properties file every time is tedious and error prone. (e.g. 4 DB's & 4 SF Orgs}

What I would like to do is define access parameters (for various SQL Server DB and Salesforce Orgs), specify DbName and SFName as http query parameters, and let mule application pick the correct parameters for connection.

How would I accomplish it? Details will help me as I am not that proficient in Mule yet.

Thanks

Kishore


回答1:


You could create one property file with a full list of the database connections:

#DB of puppies
postgres.puppies.user=mule
postgres.puppies.password=password
postgres.puppies.host=db-1
postgres.puppies.db=mule-puppies

#DB of cars
postgres.cars.user=mule
postgres.cars.password=password
postgres.cars.host=db-2
postgres.cars.db=mule-cars

UPDATED

Then, if yout want to read a query parameter from the dataweave component loading one of your Properties:

%dw 1.0
%output application/java
---
p("postgres." ++ inboundProperties."http.query.params"['db-name'] ++ ".user")

Note: Consider when QueryParameter.db-name is null you will get an exception (you should handle this exception), or, another way to do it, is by handling nulls from your own data-weave (https://forums.mulesoft.com/questions/28105/how-do-i-do-a-null-check-in-dataweave.html), e.g. when null you could define a default database

Hope this helps clarifying



来源:https://stackoverflow.com/questions/45885045/defining-various-db-salesforce-access-information-in-mule-anypoint-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!