How to create a Siddhi project and Run/Debug Siddhi files using Intellij IDEA

In this article the following topics will be covered.

  1. Creating a Siddhi project and a Siddhi file in Intellij IDEA
  2. Running a Siddhi file in Intellij IDEA
  3. Debugging a Siddhi file in Intellij IDEA

[Want to know how to setup Siddhi in Intellij IDEA? Then checkout my previous article.]

Creating a Siddhi project and a Siddhi file

Creating a new Siddhi project

  1. Go to File -> New -> Project. Select Siddhi project type and click Next button.
  1. In the next step, we are prompted to select a SDK for the project. If you haven’t already added a SDK, please follow steps under Setting up the Siddhi SDK in this article to add a new SDK.
  2. Select the SDK and click Next button.

3. Update the project name and the location and click Next button.

4. Now you have successfully created a new Siddhi project.

Creating a new Siddhi file

  1. Right click on the project and select New -> Siddhi File.

2. Enter the file name and click OK button. This will create a new file with the default app annotation.

3. Now you should have a new Siddhi file with the default app annotation.

Running Siddhi files

  1. Write a sample siddhi program as shown in below.

2. Write a event input file(input.txt) as shown in below.

NOTE: You don’t need to define an input.txt file, if you are getting events through an extension.

3. Select Edit Configurations from the toolbar.

4. Click + button and select Siddhi to add a siddhi run/debug configuration.

5. Provide a name for the configuration and select the siddhi file from the file chooser.

6. Select the event input file from the file chooser and click OK.

NOTE: You don’t need to select an input.txt file, if you are getting events through an extension.

Near the main function, in the gutter area, Run icon can be found.

7. Select Run command. This will run the Siddhi file.

8. The output will be shown in the Run window.

Debugging Siddhi files

  • Use the above provided(described under Running Siddhi files) sample siddhi file and event input file for this as well.

NOTE: You don’t need to define an input.txt file, if you are getting events through an extension.

  • Provide a run/debug configuration (described under Running Siddhi files step 3–6) if you haven’t configured yet.
  1. Add breakpoints as shown in below and select Debug command. This will start the debug process.

NOTE Siddhi only allows to add breakpoints on the beginning of a query input section or on the beginning of a query output.

2. The output will be shown in the Debug window.

That’s it! Now you know how to run or debug a Siddhi file using Intellij IDEA. Happy Stream Processing! :)

Additional:

If you use WSO2 Stream Processor, you can use the Siddhi functionality with the following additional features:

  • The Siddhi Query Editor tool with syntax highlighting and advanced auto completion support
  • The Siddhi Runner and Debugger tool
  • The Event Simulator tool
  • Run Siddhi as a server with high availability and scalability.
  • Monitoring support for Siddhi
  • Realtime dashboard
  • Business user-friendly query generation and deployment