Changing App Behavior with Properties
You can change the behavior of the app while it’s running using properties.
Application properties are variables that act as placeholders in your Mule application and are set at runtime. When you deploy an application or update an existing application in Runtime Manager, Mule runtime engine supplies the values for the property variables using the information you configure on the Properties tab.
For example, you can configure a JDBC connector in which the username is set to ${dbUsername}
and the password is set to ${dbPassword}
.
In Runtime Manager, you can set these two properties as application properties.
For sensitive information, you can protect the property values so that, after you save them in Runtime Manager, their values aren’t visible in the console or passed between the console and CloudHub 2.0. For information, see Protecting App Property Values.
You can set properties in either Anypoint Runtime Manager or a properties file. If you set properties both in the properties file in your application and in Runtime Manager, the values set in Runtime Manager always override the values in the properties file when your application deploys.
Add Application Properties in Runtime Manager
The easiest way to load properties to applications deployed to a private space is to define them on the Properties tab for the application.
To add properties:
-
From Anypoint Platform, select Runtime Manager > Applications.
-
Click the app name.
-
In the navigation menu, click Settings.
-
On the Settings page, click the Properties tab.
-
Click Table view.
Alternatively, you can click Text view and enter the key-value pair in the text field in this format:
New Key=New Value
. -
In the New Key field, enter the property name.
-
In the New Value field, enter the property value. If the property value contains spaces, enclose it in quotation marks, such as
"ApiKey 898jdey1-13232"
.If the save password feature of Chrome is enabled and includes a username for anypoint.mulesoft.com
that matches the contents of the key field, Chrome overwrites the value field with the stored password associated with that username. To work around this limitation, use Chrome in incognito mode or use another browser.In Table view, if you want to:
-
Hide the value in Runtime Manager, click Protect and then click Protect value to confirm.
-
Change a key or value, edit the text in the field.
-
Delete a property, click … > Delete property.
-
-
Click Apply Changes.
Applying changes creates a new configuration and restarts the replicas. For information, see Updating Apps Deployed to CloudHub 2.0.
Example: Using Properties to Set Environment Variables
You can configure environment variables for your application.
Properties enable you to externalize settings that change depending on the environment you’re deploying to.
For example, if you use a Mule application locally, you might configure your database host to be 0.0.0.0
.
If you deploy the same app to CloudHub 2.0, you might configure the database host to be an Amazon RDS server.
To set an environment variable using an application property:
-
From Anypoint Platform, select Runtime Manager > Applications.
-
Click the app name.
-
In the navigation menu, click Settings.
-
On the Settings page, click the Properties tab.
-
Define the variable by entering it in the Text view, in
key=value
format.In the Text view, use the backslash character ( \
) as an escape character. For example, to use:
in a key or value, use\:
in the syntax. To use\
in a key or value, use\\
in the syntax. Table view syntax requires no escape character. -
Use the environment variable in your Mule app configuration.
Add Application Properties Using a Properties File
You can add properties to an app by including a file in the property placeholder YAML file deployable application archive file.
CloudHub 2.0 then loads these properties into the application when the application starts.
Although this method is not the best practice on CloudHub 2.0 (because the Properties tab values override any with the same name in the file), you can work around this by changing options in the Mule app.
To prevent CloudHub 2.0 properties from overriding properties bundled with the deployable archive, change options in the property-placeholder
element in the Mule application.
For more information about nondefault property placeholder options, see the Spring documentation on Property Placeholder options.
Limitations
-
You can add up to 300 properties.
-
Property keys and their values cannot exceed 1024 characters.
Reserved Properties
CloudHub 2.0 reserves a set of properties and prevents apps from overwriting the values of those properties. If an application attempts to assign a value to a reserved property, CloudHub 2.0 doesn’t use the assigned value. Instead, it returns the value as set internally, without throwing an error or exception, and adds a warning message to the log.
Property | Description | Example |
---|---|---|
|
JVM name |
OpenJDK Runtime Environment |
|
JVM version |
1.8.0_342 |
|
JVM version, including dot (point) release |
1.8.0_342-8u342-b07-0ubuntu1~20.04-b07 |
|
HTTP port |
8081 |
|
HTTPS port |
8081 |
|
HTTP private port |
8081 |
|
HTTPS private port |
8081 |
For proprietary reasons, MuleSoft doesn’t make public all internal, reserved properties. CloudHub 2.0 runtime release updates might change the reserved properties. |