"In the future, every company must be able to recognize what is coming early enough to take evasive action or steer towards an emerging opportunity."[Frederick W. Smith-CEO FedEx] Wednesday, April 1, 2009
Development An event is a piece of data that represents that something happened in the real world, or in software system. e.g. Stock Tick, Weather, UserClick Wednesday, April 1, 2009
J2EE Development A partially ordered set of events form Event Cloud e.g. Set of all stock trades for GOOG within a 5 minute time window is an Event Stream. While all Stocks sold in a business day is an Event Cloud. Wednesday, April 1, 2009
Development Event Stream Processing is focused more on high-speed querying of data in streams of events and applying mathematical algorithms to the event data. Complex Event Processing includes event data analysis, but places emphasis on patterns of events, and abstracting and simplifying information in the patterns. Wednesday, April 1, 2009
An event processor is an application that performs operations on event objects, including creating, reading, transforming, aggregating, correlating or removing them. Wednesday, April 1, 2009
Development 1. Keep the data moving 2. Query on streams 3. Handle Stream Imperfections 4. Integrate Stored and Streaming Data 5. Guarantee Data Safety and Availability Wednesday, April 1, 2009
Development Capital Markets BAM - Business Activity Monitoring Supply Chain Management Flight Operations Monitoring Fraud Detection Wednesday, April 1, 2009
Type Syntax Example Simple name sensor Indexed name[index] sensor[0] Mapped name(key) sensor(‘light’) Nested name.nested Name sensor.value Wednesday, April 1, 2009
Must provide a method by name update to receive insert stream events row-by- row • The number and types of parameters declared by the update method must match the number and types of columns as specified in the select clause, in the same order as in the select clause • Wednesday, April 1, 2009
orderId, price, count(*) from OrderEvent public class MySubscriber { ... public void update(String orderId, double price, long count) {...} } Wednesday, April 1, 2009
Development • Obtain an Esper engine instance • Create a statement (using the Esper query language) • Register the statement with the engine • Create a listener (by implementing a Java interface that will be triggered when the statement evaluates to true) and attach it to the statement Wednesday, April 1, 2009
• Analogous to database views • Created using SELECT queries • Define window (view) first and insert data create window OrdersTimeWindow.win:time(30 sec) as select symbol, volume, price from OrderEvent Wednesday, April 1, 2009
Development Engine dispatches to Listener when output condition occurs. e.g. select irstream symbol, volume, price from MarketData.win:time(5.5 sec) output every 1 seconds Wednesday, April 1, 2009
Pattern Expression = Pattern atoms + Pattern Operators every (spike=ServiceMeasurement(latency>20000) or error=ServiceMeasurement(success=false)) select s from pattern [every s=SubmitOrderEvent -> (timer:interval(30 sec) and not OrderAcceptedEvent(theOrder.id=s.theOrder.id))] Wednesday, April 1, 2009
select name, healthy_temp from TempEvent.win:time(60 sec) temp, sql:mydb3 [' select name,healthy_temp from Player where name = ${temp.playerName} and $ {temp.temperature} > healthy_temp '] Wednesday, April 1, 2009
Innovating J2EE Development public class InstrumentRepository { public static Exchange[] getExchangesForSymbol(String symbol) { ... } select ord, eligibleExchanges from TheOrder as ord, method:com.ociweb.jnb.esper.InstrumentRepository.ge tExchangesForSymbol(ord.symbol) as eligibleExchanges } Wednesday, April 1, 2009
J2EE Development Filtering: e.g. Click-stream analysis: a filter may be used to capture the trades that originate from a certain set of IP addresses. Wednesday, April 1, 2009
J2EE Development In Memory Caching: e.g. Click-stream analysis: a typical application may hold the recent clicks and searches performed by the users, coupled with the relevant historical and reference information. Wednesday, April 1, 2009
J2EE Development Aggregation over Windows: e.g. Click-stream analysis: it is often useful to compute the number of visitors who click on a particular link within a specified time interval. Wednesday, April 1, 2009
J2EE Development Database Lookups: e.g. Trading: a trading application may look up historical price for a stock, or certain information about an order, or certain rules and regulations stored in a database. Wednesday, April 1, 2009
J2EE Development Database Writes: e.g. Click-stream analysis: storing the raw click-stream history, together with derived data, in the database Wednesday, April 1, 2009
J2EE Development Correlation (Joins): e.g. Trading: correlating information from multiple exchanges to find arbitrage opportunities. Wednesday, April 1, 2009
J2EE Development Event Pattern Matching: e.g. Fraud detection: fraud patterns are often described as a sequence of events, in one or more streams. Wednesday, April 1, 2009
J2EE Development Hierarchical Events: e.g. Order Processing: Purchase Order can have multiple items which needs to be processed differently. Wednesday, April 1, 2009
J2EE Development Dynamic Queries: e.g. Trading environments: every trader can enter their subscriptions like X=MSFT, Y=.1%, Z=10 am. Wednesday, April 1, 2009
// Better performance select * from RFIDEvent // Less good performance select assetId, zone, xlocation, ylocation from RFIDEvent Wednesday, April 1, 2009