Routing Events8% of the exam

Choice router conditions and route order

Predict which Choice route runs from its DataWeave `when` expressions (first true wins, `otherwise` as the default), avoid String versus Number and Boolean comparison traps, and choose DataWeave `if`/`else` or the First Successful router when Choice is the wrong tool.

Official exam objective
Apply correct processors/syntax to route messages using DataWeave conditions within a choice router, and predict outcomes.

~7 min read · 9 practice questions ·

What the exam expects

  • Predict which route of a Choice router runs, given the when expressions in their declared order and an input event.
  • Write the Mule 4 XML for a Choice router: <choice>, one or more <when expression="#[...]"> elements and an optional <otherwise> default route.
  • Spot DataWeave conditions that fail because of type: Strings from query parameters compared with Numbers, and == versus ~= against Booleans.
  • Predict the payload and variables after a route that calls a subflow.
  • Choose DataWeave if/else when routes only differ in a value, and the First Successful router when the next route must run only after a failure.

Key terms:

  • Choice router: runs exactly one route, chosen by DataWeave expressions.
  • when route: a routing option whose expression holds the condition.
  • Default route: the <otherwise> element, labelled Default in Studio, which runs when no expression is true.
  • First Successful router: tries routes in order until one completes without an error.
  • ~=: the DataWeave equality operator that coerces one operand to the other's type.

Key facts

Routes that run
Detail
Only one: the first when whose expression is true
Later expressions
Detail
Not checked once one is true
No expression true
Detail
The default (<otherwise>) route executes
<otherwise>
Detail
Optional child of <choice>; Studio labels it Default
Processors per route
Detail
Any number in each when and otherwise
Condition language
Detail
DataWeave, in the expression attribute
Mixed-type relational operands
Detail
Right operand coerced to the left operand's type
"true" == true vs "true" ~= true
Detail
false vs true
DataWeave if
Detail
Every if must have a matching else
First Successful
Detail
Next route runs only after an error; error if none succeed
Sources for this section (4)
  • What does ('1' ~= 1) return, and why?
  • Why does a new Choice router in Studio already show two routes?
  • When does the else if branch of a DataWeave if supply the value?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the MuleSoft Developer pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 40 lessons of the MuleSoft Developer guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Practice exams purchase adds inline bank questions and topic practice (9 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the MuleSoft Developer exam