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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • 2-Tier Architecture vs 3-Tier Architecture in DBMS
  • The Bill You Didn't See Coming
  • Doubly Linked List in Data Structures and Algorithms
  • What Is GraphQL?

Trending

  • How to Build a Scalable SaaS Product Architecture
  • Top Gen AI Frameworks for Go in 2026: A Hands-On Comparison
  • Claude Code Superpowers: The 5-Tool Stack That Ends Limits and Context Amnesia
  • Managing Technical Debt in AI-Generated Code

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. Databases
  4. Mule 4 Dynamic Evaluate Component

Mule 4 Dynamic Evaluate Component

This article explains about Dynamic Evaluate Component in Mule which helps in executing dynamic dataweave scripts.

By 
Praneeth Venishetty
·
Oct. 05, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
8.3K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Dynamic Evaluate

  • A behavior that allows you to dynamically select the dataweave script instead of hardcoding the script in the Transform Message component.
  • This component lets you execute an expression that eventually evaluates a Dataweave script wherein the expression being executed here again results in a dataweave script.
  • This way we can dynamically select the dataweave script to be executed concerning any varying parameter.

Functional Scenario

Assume we are in API led connectivity approach where we have 

  •  A set of Experience APIs invoked by different applications like Salesforce, SAP, Mobile Apps, Web Apps, etc for the same functionality.
  • A Process API to orchestrate the response coming from System API concerning source of the request.
  • A System API which connects to backend systems like databases etc to get the required data.

systemAPI

All the client applications in our example may not require all the data retrieved from system API. So, in the process API orchestration if we had to respond to different client applications with different response structures, in the general case we will end up designing each flow for each client app to achieve this.

But using a dynamic evaluate component without using a choice router and without defining different flows respective to different client applications we can achieve this dynamic response.

Let us check the example in Anypoint studio

  • Create a mule project
  • Create dwl files as shown below specific to each Client Application

mobileApp

  • Set below payload in Transform Message Component and assume it to act as a response from system API

JSON

  • Create a mule variable to store the dynamic dataweave client-specific script using readUrl() in which dw file to be picked is based on the queryParam(appName) passed by the client application

output

  • Configure Dynamic Evaluate Component to read the dynamic script and run on the payload.

dynamic evaluate

  • Final Mule Flow

transform message

deploy test

Hope you understood the concept and the example, please provide feedback in the comments. 

Thank you!

mobile app API Database Flow (web browser) Data (computing) Payload (computing) Concept (generic programming)

Published at DZone with permission of Praneeth Venishetty. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • 2-Tier Architecture vs 3-Tier Architecture in DBMS
  • The Bill You Didn't See Coming
  • Doubly Linked List in Data Structures and Algorithms
  • What Is GraphQL?

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook