Apisero is now part of NTT DATA - Learn more.

Search
Close this search box.

Dynamic Configurations In Anypoint Studio

Authors: Rishi Uniyal & Atul Sharma

Prerequisites:

This blog contains steps on how to provide dynamic connector configurations based on any particular condition. This method would work for all the processing connectors.

Real time Scenario:

To set up the configuration for multiple instances the generic way is to have multiple configurations for the end systems. So to avoid creating multiple configurations we came up with the approach of dynamic configuration setup so that the configuration values are set based on the scenario and the instance it needs to be called.

Setup for dynamic configuration:

For example will create the dynamic configuration for ServiceNow and SFTP servers, we came up with the following approach: 

1) ServiceNow instances

  • Suppose we are using ServiceNow connector for creating Incidents in the ServiceNow portal using MuleSoft and require it to make connections to multiple ServiceNow instances dynamically. 
  • For this, the connector configurations like host, username and password would be first stored in separate variables according to any specific condition. The format should be text/plain.
  • Below is an example of a variable “host” containing the host value of a specific ServiceNow instance.
  • These values are selected from the properties file based on the tenantId that we receive in the header of  the request.
  • Below is the request containing tenantId in the header of the request:
  • Similarly, we will have separate variables for other credentials like username, password etc.
  • Now in ServiceNow connector configuration, we refer to these variables to the configuration values as shown below:
  • Hence, by providing the configuration values through variables we can achieve dynamic connections. 

2) SFTP instances

  • Suppose we are using SFTP List files connector for reading files from SFTP server using MuleSoft and require it to make connections to multiple SFTP servers dynamically. 
  • One SFTP server uses basic authentication while the other uses a .ppk file for authentication.
  • For this, the connector configurations like host, port, username and password would be first stored in separate variables according to any specific condition. The format should be text/plain.
  • Will iterate over the given SFTP servers to read the files using ForEach, configuration values of those would be selected from properties files as below.

Payload for iteration – 

SFTP details in properties file – 

  • Below is an example of a variable “host” containing the host value of a specific SFTP server.
  • Similarly, we will have separate variables for other credentials like port, username, password etc.
  • Now in SFTP connector configuration, we refer to these variables to the configuration values as shown below:
  • Hence, by providing the configuration values through variables we can achieve dynamic connections. 
Conclusion:

Thus, for all the connectors where we want to set up the dynamic configurations for the connectors where we have multiple instances we can use the above mentioned approach for the dynamic process.

**Note: The above mentioned approach cannot be used for  the source connectors (like HTTP Listener, On New File etc.)

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.