MCD-LEVEL-1 practice question 7 of 30

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?

Full set: 235 questions
Answer options
A: Account Type: #[flowVars.accountType]
B: Account Type: #[message.inboundProperties.accountType]
C: Account Type: # [attributes.accountType]
D: Account Type: #[vars.accountType] Correct answer
Correct Answer:
D. Account Type: #[vars.accountType]
Explanation

In Mule 4, variables created or captured using the Set Variable component are stored in the Mule event's variables collection. To access these variables within DataWeave expressions or component configurations, the vars keyword is used, followed by the specific variable name. Therefore, #[vars.accountType] is the correct DataWeave expression to retrieve and log the value of the accountType variable.

Why Incorrect

A: flowVars is a legacy Mule 3 concept and is no longer valid in Mule 4 DataWeave 2.0. B: message.inboundProperties is a Mule 3 concept; Mule 4 uses attributes for message metadata. C: attributes accesses message metadata directly (e.g., attributes.queryParams), but the question specifically asks to log the captured variable, not the attribute.

References

1. MuleSoft Official Documentation, "DataWeave Variables", Mule 4. Available at: https://docs.mulesoft.com/dataweave/2.4/dataweave-variables

2. MuleSoft Official Documentation, "Mule Events and the Mule Message", Mule 4. Available at: https://docs.mulesoft.com/mule-runtime/4.4/mule-message-structure

Scroll to Top