Skip to content

Debugging Mediation

Debugging with External WSO2 Integrator: MI

  1. Download and install the WSO2 Integrator: MI server and on your computer.

  2. Launch Visual Studio Code with the WSO2 Integrator: MI Extension installed.

  3. Select the artifact that requires debugging from the Project Overview page.

    project overview

  4. Then select the relevant resource from the Service Designer page in order to open the Diagram View of the resource.

    service designer

  5. To add a breakpoint to a mediator, in the Diagram View click on the Options icon on the right side of the mediator name and select Add Breakpoint.

    add breakpoint

    Note

    To remove a breakpoint from a mediator, click on the Options icon on the right side of the mediator name and select Remove Breakpoint.

    remove breakpoint

  6. Configure a new MI server without any previously deployed integrations to avoid conflicts by following the steps below.

    1. Open the command palette in VS Code by entering Command+Shift+P on macOS and Ctrl+Shift+P on Windows.
    2. Select MI: Add MI server from the list of available commands.
    3. Select the folder where <MI_HOME> is located.

    Current server path

    Note

    Mediation debugging with the MI for VSCode extension is supported on Windows starting from MI server version 4.3.0.

  7. Select the Run and Debug extension from the left side panel and then click on the Run and Debug button.

    run debug

  8. Select MI: Run and Debug as the debugger.

    debugger selection

Then the server will start up in debug mode and the server logs can be viewed in the Output alongside with the Debug Console.

terminal view

Remote Server Debugging

Follow the steps below to connect to and debug a remote WSO2 Integrator: MI server.

  1. Click Create a launch.json file.

    debugger selection

  2. Select MI: Run and Debug as the debugger.

    debugger selection

  3. Below content will be generated and added to the launch.json file with the default values. Update the configurations in the MI: Remote Server Run and Debug section accordingly to connect to the remote server.

    {
        "version": "0.2.0",
        "configurations": [
            {
                "type": "mi",
                "name": "MI: Local Server Run and Debug",
                "request": "launch",
                "internalConsoleOptions": "openOnSessionStart",
                "vmArgs": [],
                "properties": {
                    "type": "local"
                }
            },
            {
                "type": "mi",
                "name": "MI: Remote Server Run and Debug",
                "request": "launch",
                "internalConsoleOptions": "openOnSessionStart",
                "vmArgs": [],
                "properties": {
                    "type": "remote",
                    "commandPort": 9005,
                    "eventPort": 9006,
                    "serverHost": "localhost",
                    "serverPort": 8290,
                    "serverReadinessPort": 9201,
                    "managementPort": 9164,
                    "managementUsername": "admin",
                    "managementPassword": "admin",
                    "connectionTimeoutInSecs": 10
                }
            }
        ]
    }
    
Property Description
type Debug type - local or remote
commandPort Debug command port
eventPort Debug event port
serverHost Host of the remote server
serverPort Remote server port for HTTP Passthrough transport.
serverReadinessPort HTTP port of the Management API of the remote server
managementPort HTTPS port of the Management API of the remote server
managementUsername Username to access Management APIs
managementPassword Password to access Management APIs
connectionTimeoutInSecs Remote server connection timeout
  1. Start the remote server in debug mode.

    sh micro-integrator.sh -Desb.debug=true
    
    micro-integrator.bat -Desb.debug=true
    
  2. Select the remote server debugger option to connect with the remote server and debug the flow.

    debugger selection

Once the server is up, send a request to the WSO2 Integrator: MI and start debugging the flow.

breakpoints

You can use the below controlling panel to debug the flow by performing operations like step over, restart, pause, and stop.

debugger controls

Information provided by the Debugger Tool

When your target artifact gets a request message and when the mediation flow reaches a mediator marked as a breakpoint, the message mediation process suspends at that point.

There are two segments in the Variables section, namely Server Internals and Message Envelope.

variables

You can view the message payload in the Message Envelope section and you can view the message mediation properties in the Server Internals section.

The Server Internals section contains properties of the following property scopes.

  • Axis2-Client Scope properties
  • Axis2 Scope properties
  • Operation Scope properties
  • Synapse Scope properties
  • Transport Scope properties

These properties can be further expanded in order to view information on the property keys and values of them as shown below.

properties expanded