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
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. MuleSoft Dataweave Language: Reading Properties From Files Dynamically

MuleSoft Dataweave Language: Reading Properties From Files Dynamically

This quick tutorial will show you how to read a properties file dynamically in Mule, using MuleSoft's Dataweave language.

Yasir Siraj user avatar by
Yasir Siraj
·
Jun. 05, 17 · Tutorial
Like (6)
Save
Tweet
Share
18.97K Views

Join the DZone community and get the full member experience.

Join For Free

In this tutorial, we will see how we can use MuleSoft's Dataweave language to read a properties file dynamically.

As a first step, let's create a new Mule project using Anypoint Studio. After creating the project, let's define our code list as follows:

GB=United Kingdom
USA=United State of America
DE=Germany
JPN=Japan
CHN=China

We will name it 'codelist.properties.' Place it under your Mule project 'src/main/resouces' folder.

Image title

Next, let's add the properties file in our global configuration. We will add a new property place holder. For this step, go to Global Elements -> Create -> Property Place.

Image title

Let's create a flow with an HTTP inbound connector.

Image title

We have set the path to be '/country' and Allowed Methods to be 'GET' only. For HTTP Connector configuration, we have used the following settings:

Image title

As a next step, let us assume we will get a query parameter named 'code' in our request. We will set that parameter in a local variable named 'countryCode.'

Image title

In the final step, lets add a Transform Message component and call the dataweave function 'p.'

Image title

We can test the service after deploying the application in Anypoint Studio. You can use a browser or Postman to hit the service.

For request, try any one of the following URL's.

http://localhost:8081/country?code=GB

http://localhost:8081/country?code=USA

http://localhost:8081/country?code=DE

http://localhost:8081/country?code=JPN

The response will come back as follows (based on the code you've sent across as the query parameter):

{
  "country": "United Kingdom"
}

I hope this article helps you understand how to read properties file dynamically using the Mulesoft Dataweave language.

Property (programming) MuleSoft

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • GPT-3 Playground: The AI That Can Write for You
  • Implementing Infinite Scroll in jOOQ
  • Silver Bullet or False Panacea? 3 Questions for Data Contracts
  • Top Five Tools for AI-based Test Automation

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: