Debugging Mule Applications
Debug your Mule application using the embedded debugger in Anypoint Code Builder.
The process for debugging a Mule app is:
-
Set breakpoints to pause the execution of a flow at lines that you want to inspect or fix.
Breakpoints are markers that you add on line numbers in a configuration XML file for a Mule application that you are developing.
-
Start execution of a flow in your Mule application.
For example, trigger an HTTP Listener or configure a Scheduler component.
-
When the execution stops at a breakpoint, use the debug toolbar to navigate, inspect, and fix issues.
-
After addressing an issue at a breakpoint, redeploy (hot deploy) the running instance of your application.
-
Execute your flow again, and continue debugging until you address all issues.
Debug Console Overview
1 | Start Debugging: Starts an instance of a Mule application in debugging mode. |
2 | Debug Toolbar: Controls debugging of Mule applications.
See Debug Toolbar. |
3 | Variables panel: Provides Mule event and parameter data.
The Mule event includes message payload and attribute details, as well as Mule variable data. The parameters include component data, such as the component name. |
4 | Run and Debug (MuleSoft) icon: Opens the Run and Debug panel, where you can click Start Debugging (F5) and find debugging information.
Keyboard shortcut: Cmd+Shift+d (Mac) or Ctrl+Shift+d (Windows) |
5 | Watch panel: Helps you evaluate variables and expressions. |
6 | Call Stack panel: Identifies the functions or procedures that are currently in the stack. |
7 | Breakpoints panel: Lists all breakpoints in your Mule application. |
8 | Terminal console: Displays the output of the Maven build process and the results of the deployment to the embedded Mule Runtime engine. |
9 | Breakpoint icon: Identifies a line in the configuration XML to pause execution of the flow so that you can check for and fix any issues. |
10 | Breakpoint icon: Identifies a component that contains one or more breakpoints. |
Add a Breakpoint
A breakpoint enables you to pause your Mule application at a specific place to learn more about what is happening. You can either add a breakpoint to a configuration XML file or to a component in the canvas UI.
Add a Breakpoint in a Configuration File
To add a breakpoint in a configuration XML file:
-
In Anypoint Code Builder, on the Explorer view, open your configuration XML file, for example,
my-project-name.xml
. -
Open the Run and Debug panel.
Show me how
-
Click the (Run and Debug) icon in the activity bar.
-
Use the keyboard shortcuts:
-
Mac: Cmd+Shift+d
-
Windows: Ctrl+Shift+d
-
-
In the desktop IDE, select View > Run.
-
In the cloud IDE, click the (menu) icon, and select View > Run.
-
-
Click the line number in your
<flow-ref>
component to add a breakpoint on that component:You can also use F9 to add a breakpoint to the current line.
-
In your configuration XML file, add two more breakpoints for the
<db:select>
and the<set-variable>
components.All breakpoints appear in the Breakpoints panel:
Add a Breakpoint to a Component in the Canvas UI
To add a breakpoint to a component in the canvas UI:
-
In Anypoint Code Builder, on the Explorer view, open your configuration XML file, for example,
flights-implementation.xml
. -
Open the Run and Debug panel.
Show me how
-
Click the (Run and Debug) icon in the activity bar.
-
Use the keyboard shortcuts:
-
Mac: Cmd+Shift+d
-
Windows: Ctrl+Shift+d
-
-
In the desktop IDE, select View > Run.
-
In the cloud IDE, click the (menu) icon, and select View > Run.
-
-
In the canvas UI, right-click on the component you want to add a breakpoint to:
-
Select Add Breakpoint.
A breakpoint icon appears on the component and in the configuration XML for that component.
Run Your Application in Debug Mode
After setting up your debug conditions, run a debug session and evaluate your Mule application at each breakpoint:
-
Open the Run and Debug panel.
Show me how
-
Click the (Run and Debug) icon in the activity bar.
-
Use the keyboard shortcuts:
-
Mac: Cmd+Shift+d
-
Windows: Ctrl+Shift+d
-
-
In the desktop IDE, select View > Run.
-
In the cloud IDE, click the (menu) icon, and select View > Run.
-
-
Click the (Start Debugging (F5)) icon for Debug Mule Application.
Alternatively, if the Start Debugging (F5) icon is not present:
-
Click Run and Debug.
-
If a Select debugger dropdown menu appears, select Mule Xml Debugger to initiate the debugging session:
When the application deploys successfully, you see a
DEPLOYED
log message in the output panel:********************************************************************** * - - + DOMAIN + - - * - - + STATUS + - - * ********************************************************************** * default * DEPLOYED * **********************************************************************
-
Selecting Run > Start without Debugging produces an error. |
Anypoint Code Builder packages your application and deploys the application to the embedded Mule runtime engine. A terminal opens so you can view the status:
The terminal displays a message and the status bar turns red to indicate that the application is running.
Use buttons on the debug toolbar to control debugging of Mule applications.
Debug Toolbar
1 | Continue F5
Proceeds to the next breakpoint, if present, and pauses execution of the application. Otherwise, continues to the end of the application. |
||||||
2 | Step Over F10
Proceeds to the next component in the flow, where execution pauses.
At a Flow Ref component ( Step Over DetailsConfiguration XML example:
Step Over behavior:
|
||||||
3 | Step Into F11
Proceeds to the next component in the flow, where execution pauses.
At a Flow Ref component ( Step Into DetailsConfiguration XML example:
Step Into behavior:
|
||||||
4 | Step Out Shift+F11
Exits the current flow and attempts to return to a previous flow. If a previous flow doesn’t exist, the debugger behaves like Continue. |
||||||
5 | Restart Shift+Cmd+F5 (Mac) or Shift+Ctrl+F5 (Windows)
Stop and restart the application without packaging new dependencies, such as new connector dependencies in your |
||||||
6 | Stop Shift+F5
Stop execution of the application. The next debugging session that you start packages the application with any new dependencies. |
Perform a Hot Deploy When Debugging
As you debug your application, periodically perform a hot deployment.
A hot deployment updates a running instance of your application but does not package new dependencies, such as new connector dependencies in your pom.xml
.
To perform a hot deploy:
-
Ensure your Mule application is running in the IDE.
-
Make an update to your application.
-
Click the Save and Hot-deploy to Mule Runtime (lightning) icon to deploy the application with the change: