Debugging a Siddhi Application
WSO2 Stream Processor Studio allows debugging tasks to be carried out to ensure that the Siddhi applications you create and deploy are validated before they are run on an actual production environment. To debug a Siddhi application, you can run it in the debug mode, apply debug point and then run event simulation so that the specific debug points are analyzed.
To run a Siddhi application in the debug mode, follow the procedure below:
Start the Stream Processor Studio following the instructions in Stream Processor Studio Overview.
You are directed to the welcome-page. In this scenario, let's use the existing sample Siddhi application named
ReceiveAndCountto demostrate the debugging functionality. To open this Siddhi application, click on the sample.
TheReceiveAndCountSiddhi application opens in a new tab.In order to debug the Siddhi file, you need to first save it in the
workspacedirectory. To do this, click File => Save. In the Save to Workspace dialog box that appears, click Save.To run the Siddhi application in the debug mode, click Run => Debug.
As a result, the following log is printed in the console.
Also, another console tab is opened with debug options as shown below.Apply debug points for the required queries. To mark a debug point, you need to click on the left of the required line number so that it is marked with a dot as shown in the image below.
Simulate one or more events for the
SweetProductionStreamstream in the Siddhi application. The first line that is marked as a debug point is highlighted as shown below when they are hit.
Two viewing options are provided under both Event State and the Query State sections of the Debug tab for each debug point hit as shown above.To expand the tree and understand the details of the processed attributes and their values etc., click the following icon for the relevant query.
When you observe the details, note that the value foroutputDatain the Event State section is null. This is because the debug point is still at begining of the query. Also note that the value calculated via thecount()function is still displayed as0in the Query State section.
The following icons are displayed in the Debug tab of the console:Once you navigate to next debug point and see the details by clicking the plus signs as mentioned above you can further analyze the processed attributes and its values as shown below. Note that after the count() aggregate function, a value of 1 has been calculated.