Information is the lifeblood of a software solution. Just like you and I won't live long without a continuous flow of blood coursing through our veins, software solutions will die an untimely death if they lose their supply of information and their ability to respond appropriately. I know my analogy might be a stretch but it does illustrate a point...information is not a static element within a software solution. Instead, information moves through an application as users do their jobs. As it moves, or flows, the nature of the information can change—its values, its importance, or even its relevance. You need to monitor the flow of information to identify trends and respond to them in a timely fashion. This type of situation is well-suited for Avaya's Event Processing Technology.
In previous articles, we have built a business case for developing real-time response, SOA-based solutions and explained the major language components of Avaya's Event Processing Language (EPL). If you have not already done so, I recommend that you read both of these articles before continuing with this article as I will be using concepts and terminology defined previously.
In this article, I will explain how to use Avaya's EPL tools to build a Baseball Spring Training News Service.
Identify Data Trends and Build Real-Time Responses Using Avaya EPL
EPL uses the concept of data streams to identify and to respond to data in the environment. In EPL, a stream is a sequence of events occurring over time. These streams define a data entity type that can then flow through the Avaya Event Processing Server. For example, during baseball spring training, data concerning players is generated on a minute-by-minute basis during games and workouts. At other times, the news may flow at a slower pace. By creating a set of related streams, you can build queries that look for certain trends or values that exist in the Players' news stream. By analyzing this news stream, you can create a simple Breaking News alert service that reports when major events are occurring during spring training.
Stream Objects Define Data Entities
A Stream object in EPL is typically a set of name/value pair that defines the stream's data elements. A good way to understand streams is to compare them to tables in a database. Just like a database table, a stream object contains one or more related fields. Each field can be a different data type (i.e. string, integer, date, double, etc. or even a more complex Java type, such as Map or a custom bean) and can also be defined as Nullable (i.e. not required). Figure 1 shows a Player stream I created using the EPL Studio development environment.
 | |
| Figure 1. A Player Stream Built Using EPL Studio |
Author's Note: You Have More Than One Option When Creating Stream Objects You are not limited to using only name/value pairs when building a stream object. EPL also supports the use of XML schema definitions (XSDs) and Java Beans to define a stream object. However, these choices are less popular given the prep-work and overhead required. Name/value pairs may be created on the fly, making them easy to instantiate when needed during run-time. XML schemas and Java Beans must already exist before you can utilize them. |
Event Definitions Take Action When Desired Information Exists
As data streams receive new information, events look for the existence of defined data conditions and respond when the conditions exist. Going back to the database analogy, an event is a combination of a query and a trigger. An event queries stream data and then triggers an action. This action could be anything you define. For example, you could define an event that monitors the Player stream and inserts items in a NewsTicker stream if it finds items related to your favorite player.
An event definition queries data streams through the use of the following clauses:
- On - this clause defines the trigger that will cause the evaluation of the event's rules. A good example is a timer that scans the player stream every five minutes for any stats involving your favorite player.
- When - this clause contains the rule to evaluate. Think of the When clause as the Where clause in a SQL statement. The when clause defines the values that identify your desired data.
- Then - this clause defines the actions that should execute when the event's rules (the On and When clauses) find a match.
An example of the even definition syntax looks like this:
ON
stream_name
WHEN
stream_name.field = 'value'
THEN
action_name(parameter)
To show how quickly you can get started developing with EPL, let's build a couple of stream objects and an event definition that, together, serve as a rudimentary news ticker that scans for baseball related news.
What You Need to Begin Developing with EPL Avaya makes it easy to begin developing with EPL. All you need to do is join its DevConnect program to gain access to the development resources you need.
After completing your free registration, you can download a fully-functioning Event Processor development environment. Microsoft Windows and Linux installs are supported; all you need to do is download the appropriate version for your environment, install it, and start developing.
Here are the related links: |