com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_link3' is unknown.

Creating a Simple Siddhi Application

Introduction

The first tutorial introduces you to WSO2 SP and explains some of its basic concepts.

For this tutorial, let's consider a scenario where Sam, the foreman of the Sweet Factory wants a name-wise total for all the categories of sweets produced until now. During a given run, each Sweet Bot in the factory produces a batch of sweets and generates an event that contains information about the name of the sweet it produced and the quantity produced.

Individual events generated by four different worker Sweet Bots are as follows:

Input EventSweet Bot NoItemQuantity
11Toffee11
22Gateau2
33Gingerbread5
44Gateau8

The foreman expects to receive the following output from WSO2 SP if the above events are sent in the given order.

Output EventItemQuantity
1Toffee11
2Gateau2
3Gingerbread5
4Gateau10

This tutorial shows how this data is processed to generate the expected output if it is sent to WSO2 SP to be analyzed.

This tutorial covers the following:

  • Creating a simple Siddhi Application
  • Simulating input to the Siddhi Application


Before you begin:

  1. Install Oracle Java SE Development Kit (JDK) version 1.8* and set the JAVA_HOME environment variable.
  2. Download the WSO2 SP.


Tutorial steps

The Siddhi application required for this scenario can be created in two methods:

  • The Source View of WSO2 Sream Processor Studio where you can write the application in Siddhi Query Language.
  • The Design View of WSO2 Stream Processor where you can design the Siddhi application in a graphical interface by dragging and dropping Siddhi components and linking them as required.

Click on the relevant tab to create the Siddhi application in the preferred interface.

Generating the output

Let's see how the Siddhi application you created functions when it is deployed and run in WSO2 SP. For the purpose of learning, the following four events generated by the Sweet Bots are simulated in WSO2 SP via the Event Simulation tool. 

To check whether your Siddhi application generates this output, follow the steps below:

  1. In the Stream Processor Studio, click the following icon for event simulation. This opens the left panel for event simulation.
  2. In the Single Simulation tab, do the following:

    1. In the Siddhi App Name field, select SweetTotalApp.
    2. In the Stream Name field, select SweetProductionStream.
    3. In the name field, enter Toffee .
    4. In the amount field, enter 11.
    5. Click Start and Send. This will start the siddhi app in run mode and send the event. The following is logged in the console. 
    6. Repeat these substeps to send three more events. Change the value for the name and amount fields as follows.

      nameamount
      Gateau2
      Gingerbread5
      Gateau8

      The resulting output events should be logged as follows.

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.