The following Mule configuration fragment defines a global property called env, a dynamic configuration properties file (based on the env property), and an HTTP connector with variable configuration:
<global-property doc:name="Global Property" name="env" value="qa" />
<configuration-properties doc:name="Configuration properties" file="${env}.yaml" />
<http:listener-config name="HttpListenerConfiguration"
doc:name="HTTP Listener Configuration"
host="${host}"
port="${port}"
basePath="${path}" />
This example uses Spring’s property placeholder resolution mechanism. The variable bits: the base path, host, and port are clearly visible and can vary for each environment where this connector gets deployed in.
When deploying your application, you can dynamically replace the env property with the particular environment to which you’re deploying, such as qa or prod. This causes the Mule application to load a different .yaml file with properties specific to the configured environment.
To provide values for these environment variables, we use a Yaml configuration file for each environment:
Properties File: qa.yaml
path: "test/products"
host: "localhost"
port: 8082
Properties File: prod.yaml
path: "products"
host: "www.acme.com"
port: 8081