Mule4 - Dynamic Evaluate - Processor/Component

 Dynamic Evaluate:

The Dynamic Evaluate component/processor in Mule4 evaluates an expression to select DataWeave script, and then executes the new script to generate a result. This behavior enables you to dynamically select the script, instead of hardcoding it into the Transform Message component based on condition.


Usecase/scenario:

1. DataWeave script varies based on program id and its security id .

2. if there are 15 programs currently and may grow in future, In this scenario instead of writing if elseif condition based on program id and security id in a single dataweave script.

3. Modularize by  writing separate dwl script for each program id and security id combination.

4. Name each dataweave script such a way that program id and security id are part of it in order to resolve which script to dynamically evaluate at runtime.

Example of dataweave without "Dynamic Evaluate" Component(illustration only):



Example of dataweave with "Dynamic Evaluate" component:
here each if condition is translated to dwl file with file name contains the programId and securityId in order to pick corresponding file dynamically at runtime.


Building/reading dynamic dwl script can be done in 3 ways.

1. Using Transform component
2. Using File Component(File Reader)
3. DB Component(by storing dwl scripts in Database).

Using Transform.




Using File Component(File Read): Assuming that onPrem mule server and in anypoint studio - that these dwl files are copied to server location.






Comments

Popular posts from this blog

Mulesoft Certified Developer-Level2 - Study Material

Mule4- Salesforce Connector- Version-10.4.2 - Create job bulk api v 2 - ClientInputError:LineEnding is invalid on user data. Current LineEnding setting is LF

Salesforce Certified MuleSoft Platform Architect - Level1 - Reference Notes