Contact Us 1-800-596-4880

DataWeave Expression Watches

When debugging your Mule application, you may need to evaluate a specific expression while your flow’s execution is paused. You can write a DataWeave expression to evaluate or inspect any message property.

If your expression is a declaration, the debugger returns boolean. Otherwise, it returns the value. For example, you can set:

  • One expression to evaluate if the method for a request is GET:

    #[attributes.method == "GET"]
  • And another expression to inspect the payload of the message:

    #[payload]

The first expression returns either true or false, while the second expression displays the value of the payload at that particular breakpoint.

You can also save these evaluations as expression watches so that the debugger displays the result of these evaluations every time the execution of your flow stops at a breakpoint.

Evaluate a DataWeave Expression

  1. After the debugger stops the execution at your breakpoint, write the Dataweave expression in the Evaluate DataWeave Expression view, and select Evaluate:

    Debugger with message flow, listener, set payload, logger, and DataWeave expression evaluator with Evaluate Expression button

    The result of the evaluation displays in the Evaluate DataWeave Expression view.

    A code editor displaying the method to set the payload and media type in DataWeave

You can also edit the event properties or attributes:

  1. In the Evaluate DataWeave Expression view, right-click the property value or attribute, and select Update value…​:

    A contextual menu with options to navigate to the class, duplicate the expression, add the watch, or copy the value
  2. Edit the value and select Set.

    A window with an editing field and a Set button

Add a DataWeave Expression Watch

To instruct Studio debugger to watch for an expression:

  1. In the Evaluate DataWeave Expression view, write your DataWeave expression, and select Add to watch:

    An arrow directs you to a button labeled

    Studio displays the new expression watch in the Mule Debugger view:

    A debugger window displaying a null payload