Writing first Apama program in EPL

SoftwareAG Apama is a complex event processing platform to monitor rapidly moving event data feeds. It helps you detect and analyze important patterns of events and promptly acts on critical events.

Apama program written in EPL (event processing language) consists of following important components
  • event type definitions 
  • monitors
  • actions
  • listeners
  • variables
  • packages

Writing your first program in Apama is the best way to get started and understand these components.

1. Start Apama studio and create a new project


2. In the project name field type name of your project as 'HelloWorldProject' and click finish


3.  You will see following folders created in the project view. If you don't see all the folders shown below, click on the spectacle icon and they should be visible. We will not go into the significance of each folder for this simple exercise.

 

4. Right click on eventdefinitions folder and create a new monitorscript file.




You can create the event definition as shown in the code sample below

    
 event HelloWorld {
   string message;
 }


5. Once you have created event, you can start looking it by writing a monitor.  We will just print a simple message on console whenever this event is detected by Apama correlator engine. Right click on the monitors folder and create a new monitorscript file HelloWorldMonitor.mon

You can create the monitor script as shown in the code sample below
 
 monitor HelloWorldMonitor {
   action onload() {
     HelloWorld hw;
            
       on all HelloWorld():hw {
         print "Hello World, I got the message - " + hw.message;
       }
   }
 }


6. Start the correlator and send the message to it to test your first Apama program




Nice!