Question 41
Choose 1
A web client submits a request to http://localhost:8081?accountType=personal. The query parameter is captured using a Set Variable transformer to a variable named accountType.
What is the correct DataWeave expression to log accountType?
What is the correct DataWeave expression to log accountType?
Correct answer:
D. Account Type: #[vars.accountType]
Explanation:
In Mule 4:
Flow variables are stored in the vars scope
After using a Set Variable transformer to capture the query parameter to variable accountType, you access it using vars.accountType
The Logger message can mix static text with DataWeave expressions using #[...] syntax
Correct syntax: Account Type: #[vars.accountType]
Key Concepts Tested:
- Mule 4 variable scope (vars vs Mule 3's flowVars)
- Accessing flow variables in DataWeave expressions
- Logger message syntax with mixed static/dynamic content
Analysis of Other Options:
A. Account Type: #[flowVars.accountType]: Incorrect. flowVars was used in Mule 3, replaced by vars in Mule 4.
B. Account Type: #[message.inboundProperties.accountType]: Incorrect. inboundProperties was Mule 3 syntax for accessing headers/parameters. In Mule 4, query parameters are in attributes.queryParams.
C. Account Type: #[attributes.accountType]: Incorrect. attributes contains message metadata (headers, query params, URI params), but once captured to a flow variable, you should use vars.accountType. Also, query params would be in attributes.queryParams.accountType, not directly in attributes.
Additional Note:
To directly access the query parameter without using Set Variable, you could use #[attributes.queryParams.accountType], but the question states it was already captured to a variable, so vars.accountType is correct.
In Mule 4:
Flow variables are stored in the vars scope
After using a Set Variable transformer to capture the query parameter to variable accountType, you access it using vars.accountType
The Logger message can mix static text with DataWeave expressions using #[...] syntax
Correct syntax: Account Type: #[vars.accountType]
Key Concepts Tested:
- Mule 4 variable scope (vars vs Mule 3's flowVars)
- Accessing flow variables in DataWeave expressions
- Logger message syntax with mixed static/dynamic content
Analysis of Other Options:
A. Account Type: #[flowVars.accountType]: Incorrect. flowVars was used in Mule 3, replaced by vars in Mule 4.
B. Account Type: #[message.inboundProperties.accountType]: Incorrect. inboundProperties was Mule 3 syntax for accessing headers/parameters. In Mule 4, query parameters are in attributes.queryParams.
C. Account Type: #[attributes.accountType]: Incorrect. attributes contains message metadata (headers, query params, URI params), but once captured to a flow variable, you should use vars.accountType. Also, query params would be in attributes.queryParams.accountType, not directly in attributes.
Additional Note:
To directly access the query parameter without using Set Variable, you could use #[attributes.queryParams.accountType], but the question states it was already captured to a variable, so vars.accountType is correct.




