esper.codehaus.org and espertech.comDocumentation
Here is an overview over the examples in alphabetical order:
Table 19.1. Examples
Name | Description |
---|---|
Section 19.3, “AutoID RFID Reader” |
An array of RFID readers sense RFID tags as pallets are coming within the range of one of the readers. Shows the use of an XSD schema and XML event representation. A single statement shows a rolling time window, a where-clause filter on a nested property and a group-by. |
Section 19.6, “Market Data Feed Monitor” |
Processes a raw market data feed and reports throughput statistics and detects when the data rate of a feed falls off unexpectedly. Demonstrates a batch time window and a rolling time window with a having-clause. Multi-threaded example with a configurable number of threads and a simulator for generating feed data. |
Section 19.12, “MatchMaker” |
In the MatchMaker example every mobile user has an X and Y location and the task of the event patterns created by this example is to detect mobile users that are within proximity given a certain range, and for which certain properties match preferences. Dynamically creates and removes event patterns that use range matching based on mobile user events received. |
Section 19.13, “Named Window Query” |
A mini-benchmark that handles temperature sensor events. The sample creates a named window and fills it with a large number of events. It then executes a large number of pre-defined queries as well as fire-and-forget queries and reports times. Study this example if you are interested in named windows, Map event type representation, fire-and-forget queries as well as pre-defined queries via on-select, and the performance aspects. |
Section 19.14, “Sample Virtual Data Window” |
This example demonstrates the use of virtual data window to expose a (large) external data store, without any need to keep events in memory, and without sacrificing query performance. |
Section 19.15, “Sample Cycle Detection” |
This example showcases the aggregation multi-function extension API for use with a cycle-detection problem detecting cycles in transactions between accounts. |
Section 19.7, “OHLC Plug-in View” |
A plug-in custom view addressing a problem in the financial space: Computes open-high-low-close bars for minute-intervals of events that may arrive late, based on each event's timestamp. A custom plug-in view based on the extension API can be a convenient and reusable way to express a domain-specific analysis problem as a unit, and this example includes the code for the OHLC view factory and view as well as simulator to test the view. |
Section 20.3, “Using the performance kit” |
A benchmark that is further described in the performance section of this document under performance kit. |
Section 19.16, “Quality of Service” |
This example develops some code for measuring quality-of-service levels such as for a service-level agreement (SLA).
This example combines patterns with select-statements, shows the use of the timer |
Section 19.10, “Assets Moving Across Zones - An RFID Example” |
An example out of the RFID domain processes location report events. The example includes a simple Swing-based GUI for visualization allows moving tags from zone to zone visually. It also a contains comprehensive simulator to generate data for a large number of asset groups and their tracking. The example hooks up statements that aggregate and detect patterns in the aggregated data to determine when an asset group constraint is violated. |
Section 19.4, “Runtime Configuration” |
Example code to demonstrate various key runtime configuration options such as adding event types on-the-fly, adding new variables, adding plug-in single-row and aggregation functions and adding variant streams and revision type definition. |
Section 19.5, “JMS Server Shell and Client” |
The server shell is a Java Messaging Service (JMS) -based server and client that send and listens to messages on a JMS destination. It also demonstrates a simple Java Management Extension (JMX) MBean for remote statement management. A single EPL statement computes an average duration for each IP address on a rolling time window and outputs a snapshot every 2 seconds. |
Section 19.11, “StockTicker” |
An example from the financial domain that features event patterns to filter stock tick events based on price and symbol. The example is designed to provide a high volume of events and includes multithreaded unit test code as well as a simulting data generator. Perhaps this is a good example to learn the API and get started with event patterns. The example dynamically creates and removes event patterns based on price limit events received. |
Section 19.9, “Self-Service Terminal” |
A J2EE-based self-service terminal managing system in an airport that gets a lot of events from connected terminals. Contains a message-driven bean (EJB-MDB) for use in a J2EE container, a client and a simulator, as well as EPL statements for detecting various conditions. A version that runs outside of a J2EE container is also available. |
Section 19.17, “Trivia Geeks Club” |
Trivia Geeks Club demonstrates EPL for a scoring system computing scores in a trivia game. |
In order to compile and run the samples please follow the below instructions:
Make sure Java 1.6 or greater is installed and the JAVA_HOME environment variable is set.
Open a console window and change directory to examples/example_name/etc.
Run "setenv.bat" (Windows) or "setenv.sh" (Unix) to verify your environment settings.
Run "compile.bat" (Windows) or "compile.sh" (Unix) to compile an example.
We need to take in events A, B and C and produce a single, combined event with the following fields:
Each self-service terminal can publish any of the 6 events below.
Add queue configurations to the messaging subsystem configuration as follows:
<jms-queue name="queue_a"> <entry name="queue_a"/> <entry name="java:jboss/exported/jms/queue/queue_a"/> </jms-queue> <jms-queue name="queue_b"> <entry name="queue_b"/> <entry name="java:jboss/exported/jms/queue/queue_b"/> </jms-queue>
<persistence-enabled>false</persistence-enabled>
insert into CountZone_G1 select 1 as groupId, zone, count(*) as cnt from LocationReport(assetId in 1, 2, 3).std:unique(assetId) group by zone select Part.zone from pattern [ every Part=CountZone_G1(cnt in (1,2)) -> (timer:interval(10 sec) and not CountZone_G1(zone=Part.zone, cnt in (0,3)))]
The classes for this example can be found in package com.espertech.esper.example.rfid
.
Some of the constraints we need to check are: