Configuring Properties in Mule 4 vs Mule 3
Read on to discover the differences between Mule 3 and Mule 4. Also learn how to use values configured within each of them.
Join the DZone community and get the full member experience.
Join For FreeMany changes have been introduced in Mule 4 in comparison with Mule 3.
In Mule 3 :
Property configuration was done using global configuration in Mule flow.
In component configurations -> Property PlaceHolder
In the selection below, you have been provided configuration to avail attribute values configured in the property file.
With simple configuration, the developer can access the value configured in the property file.
Property file:
name=Mule3Properties
Flow as below:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:context="http://www.springframework.org/schema/context" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8082" doc:name="HTTP Listener Configuration"/>
<context:property-placeholder location="configSample.properties"/>
<flow name="mule3propertyfileFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/mule3Property" allowedMethods="GET" doc:name="HTTP"/>
<set-payload value="${name}" doc:name="Set Payload"/>
</flow>
</mule>
Application deployed :
logs :
* Application: mule3propertyfile *
* OS encoding: \, Mule encoding: UTF-8 *
* *
* Agents Running: *
* DevKit Extension Information *
* Batch module default engine *
* JMX Agent *
* Wrapper Manager *
**********************************************************************
INFO 2018-05-07 22:21:38,580 [Mule.app.deployer.monitor.1.thread.1] org.mule.module.launcher.MuleDeploymentService:
**********************************************************************
* Started app 'mule3propertyfile' *
**********************************************************************
Access system to validate property file value access:
Now let's check the changes that came in Mule 4:
To avail values configured in new version Mule 4, configuration property file has to configure in the screen below.
To go to global configuration ->choose global configuration -> select configuration properties
Configure the property file that you want to access in the application for configured values.
Property file data:
name=Mule4Properties
Flow file to access property file's configured values:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<configuration-properties doc:name="Configuration properties" doc:id="c6141991-4e6e-4a8a-ab76-a3d770686d64" file="development.properties" />
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="6b71321e-97a5-4e1d-84b4-ba2645856256" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="propertyconfigurationFlow" doc:id="57c94a9d-0194-4265-bcbe-549c420eb15d" >
<http:listener doc:name="Listener" doc:id="57914745-ce3e-4cbd-8388-c886bd881c05" config-ref="HTTP_Listener_config" allowedMethods="GET" path="/getProp"/>
<set-payload value="${name}" doc:name="Set Payload" doc:id="ede5f918-ac6d-4e8e-bfc7-7f1fbfe21860" />
</flow>
</mule>
After the above configuration, start the application.
Here are the logs:
* Started app 'Mule4property' *
* Application plugins: *
* - Sockets *
* - HTTP *
**********************************************************************
INFO 2018-05-07 22:17:09,254 [WrapperListener_start_runner] com.mulesoft.agent.configuration.postconfigure.DefaultPostConfigureRunner: Initializing the scheduling.notification.internal.message.handler ...
INFO 2018-05-07 22:17:09,254 [WrapperListener_start_runner] com.mulesoft.agent.configuration.postconfigure.DefaultPostConfigureRunner: scheduling.notification.internal.message.handler initialized successfully.
INFO 2018-05-07 22:17:09,258 [WrapperListener_start_runner] org.mule.runtime.module.deployment.internal.DeploymentDirectoryWatcher:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Mule is up and kicking (every 5000ms) +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2018-05-07 22:17:09,270 [WrapperListener_start_runner] org.eclipse.jetty.server.AbstractConnector: Started ServerConnector@3d61ba5c{HTTP/1.1,[http/1.1]}{0.0.0.0:50166}
INFO 2018-05-07 22:17:09,272 [WrapperListener_start_runner] org.mule.runtime.module.deployment.internal.StartupSummaryDeploymentListener:
**********************************************************************
* - - + DOMAIN + - - * - - + STATUS + - - *
**********************************************************************
* default * DEPLOYED *
**********************************************************************
*******************************************************************************************************
* - - + APPLICATION + - - * - - + DOMAIN + - - * - - + STATUS + - - *
*******************************************************************************************************
* Mule4property * default * DEPLOYED *
*******************************************************************************************************
Access the system URL and it will show the property file configured value.
No major changes were done, only component name and it's attributes have been changed.
Thanks, MuleSoft.
Opinions expressed by DZone contributors are their own.
Comments