DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

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.

Sadik Ali user avatar by
Sadik Ali
CORE ·
May. 15, 18 · Tutorial
Like (2)
Save
Tweet
Share
28.48K Views

Join the DZone community and get the full member experience.

Join For Free

Many 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

Image title

In the selection below, you have been provided configuration to avail attribute values configured in the property file.

Image title

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:

Image title

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

Image title

Configure the property file that you want to access in the application for configured values.

Image title

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.

Image title

No major changes were done, only component name and it's attributes have been changed.

Thanks, MuleSoft.

Property (programming)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Microservices Discovery With Eureka
  • API Design Patterns Review
  • What Is a Kubernetes CI/CD Pipeline?
  • Bye Bye, Regular Dev [Comic]

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: