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 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

  • When Snowflake Lies to You: Understanding False Failures in dbt Pipelines
  • MuleSoft IDP: Enhancing Efficiency and Accuracy in Data Extraction
  • Stateless JWT Auth Microservice Architecture With Spring Boot 3 and Redis Sentinel
  • A Walk-Through of the DZone Article Editor
  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 user avatar
Praneeth Venishetty
·
Oct. 05, 20 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
8.1K Views

Join the DZone community and get the full member experience.

Join For Free

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

The likes didn't load as expected. Please refresh the page and try again.

  • 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