SlideShare a Scribd company logo
1 of 73
Download to read offline
© Extenda
CEP in Practice
Peter Norrhall – jDays 2012
peter.norrhall@extenda.se
@peternorrhall
© Extenda
Agenda
•  Complex Event Processing (CEP) an Introduction
•  Alternative CEP Open Source frameworks
•  Esper Essentials
•  Extenda’s usage of Esper
•  Additional Questions and Summary
© Extenda
Complex Event Processing (CEP)
•  Analyze and react to events
3
CEPEvent Action/Event
© Extenda
Event Definition
•  Event
•  Physical Event
•  Event in a Programming/Logical Entity
•  Non-Event – Absence of an event
4
CEPEvent Action/Event
© Extenda
Why the word ”Complex”?
•  Simple Event Processing
•  Acting on single event, filter in the ESP
•  Event Stream Processing
•  Looking across multiple events
•  Complex Event Processing
•  Looking across multiple event stream
5
© Extenda
Complex Event Processing (CEP)
•  Analyze and react to events
6
CEPEvent Action/Event
BPM/BAM
Finance (Trading/Fraud/Risk)
Network/App Monitoring
Sensor Network App
© Extenda
CEP – Event Stream Analysis
•  High Throughput (1.000-100k events/s)
•  Low Latency (ms – seconds)
•  Complex Computations
•  Detect Patterns Among Events (Event Correlation)
•  Filter Events
•  Join Event Streams
•  Trigger on events and absence of events
7
© Extenda
EP Network
Event Processing - Definitions
•  Sensors
•  Systems/Applications
•  Business Processes
•  …
•  Dashboards
•  Applications
•  Data Stores
•  Business Processes
•  …
8
Event
Producers
EP
Agent
Event
Consumers
EP
Agent
EP
Agent
EP Network
Statefull|StatelessChannel
© Extenda
Event Processing Languages
•  Rule-oriented
•  Production (Drools)
•  Active
•  Logic
•  Imperative (Storm/Disruptor)
•  Stream-oriented (Esper)
9
© Extenda
Storm – Twitter (Backtype)
10
Storm Topology
Agent
Producer
•  Scalable
•  Fault-Tolerance
•  Garantueed Data Processing
•  Easy to Deploy
© Extenda
BDD – WordCount story
Word Count	
	
Narrative: 	
	
In order to find out the most used words 	
As a Twitter Junkie	
I want to get word count information	
	
Scenario: Track word count out of randomly generated sentences	
	
Given the sentences:	
|sentence|	
|the cow jumped over the moon|	
|an apple a day keeps the doctor away|	
|four score and seven years ago|	
|snow white and the seven dwarfs|	
|i am at two with nature|	
When those are randomly selected and split 100 times	
Then the words should be counted separately
11
© Extenda
Context
•  A context is a named specification of conditions that groups event
instances so that they can be processed in a related way. It
assigns each event instance to one or more context partitions
(windows). A context may have one or more context dimensions
and can give rise to one or more context partitions.
12
© Extenda
Context Partitioning
Temporal
Every day between
08.00-13.00
Spatial
Outside the city
Less than 60 km
Context
Segmentation Oriented
All Cars Drving > 60 km/h
People older than 65
StateOriented
Weather is sunny
© Extenda
Topology & Context Partitioning
14
Shuffle Grouping
Field Grouping
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(1, new KestrelSpout("kestrel.backtype.com",
22133,
"sentence_queue",
new StringScheme()));
builder.setBolt(2, new SplitSentence(), 10)
.shuffleGrouping(1);
builder.setBolt(3, new WordCount(), 20)
.fieldsGrouping(2, new Fields("word"))
© Extenda
Demo – WordCount Storm
15
© Extenda
WordCountBolt
16
public static class WordCount extends BaseBasicBolt {
Map<String, Integer> counts = new HashMap<String, Integer>();
@Override
public void execute(Tuple tuple, BasicOutputCollector collector)
String word = tuple.getString(0);
Integer count = counts.get(word);
if(count==null) count = 0;
count++;
counts.put(word, count);
collector.emit(new Values(word, count));
}
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("word", "count"));
}
}
© Extenda
Disruptor
17
http://www.slideshare.net/trishagee/introduction-to-the-disruptor
© Extenda
Disruptor
18
Input
Disruptor
Output
Disruptor
Receiver Publisher
Journaler
Replicator
Unmarshaller
Marshaller
Business
Logic
Processor
© Extenda
Event Sourcing
19
Event Sourcing ensures that all changes to
application state are stored as a sequence of events.
Not just can we query these events,
•  we can also use the event log to reconstruct past
states,
•  and as a foundation to automatically adjust the
state to cope with retroactive changes.
http://martinfowler.com/eaaDev/EventSourcing.html
© Extenda
Disruptor
20
© Extenda
MacBook Pro i7
21
© Extenda
Other sample patterns
22
© Extenda
Demo – WordCount with Disruptor
23
© Extenda
Comparison
Framework/Method Sentences / second
Storm 896
Disruptor 802568
24
© Extenda
Storm/Disruptor
•  High Throughput (1.000-100k events/s)
•  Low Latency (ms – seconds)
•  Complex Computations
•  Detect Patterns Among Events (Event Correlation)
•  Filter Events
•  Join Event Streams
•  Trigger on absence of events
25
© Extenda
Computation (Patterns)
•  Business Event Processing (BEP)
•  Event Stream Processing (ESP)
26
Aggregator
Splitter
Enricher
Filter
Stateless Statefull - Patterns
© Extenda
Drools – Business Event Processing
•  Drools Guvnor – Business Rules Manager
•  Drools Expert – Rule Engine
•  jBPM – Process / Workflows
•  Drools Fusion – Event Processing
27
© Extenda
Esper – Event Stream Processing
•  Pattern Detect – Event Processing Language (EPL)
1.  Filtering
2.  Matching
3.  Derivation
28
© Extenda
Event Stream vs SQL
29
SQL : select word, count(*)
from WordEvent !
group by word!
EPL : select word, count(*) !
from WordEvent:win:time(1 min)
group by word!
© Extenda
Esper Building Blocks
•  Event
•  Statement
•  Sending Events
•  UpdateListener
30
© Extenda
(Immutable) Event – POJO or Schema
public class WordEvent {	
	private final String word;	
	public WordEvent(String word) {	
	 	this.word = word;	
	}	
	public String getWord() { return word; }	
}	
or
create schema WordEvent as (word string)
31
© Extenda
Statement (Stream)
@Name("WordCountBolt”)	
select word, count(*) as count from WordEvent group by word	
	
EPStatement	
  wordCountStmt	
  =	
  	
  
	
  	
  epService.getEPAdministrator().createEPL(wordEventStmt);	
  
32
© Extenda
Sending Events
epService.getEPRuntime().sendEvent(new WordEvent(word));	
	
Or	
	
Map<String,String> map = new HashMap<String, String>();	
map.put("word", word);	
epService.getEPRuntime().sendEvent(map, "WordEvent");	
	
Or 	
	
Using EsperIO	
33
© Extenda
UpdateListener
epService.getEPAdministrator().getStatement("WordCountBolt").addListener(wordCountListener);	
	
public class WordCountListener implements UpdateListener {	
@Override	
public void update(EventBean[] newEvents, 	
	 	 EventBean[] oldEvents) {	
System.out.println("Word ” + newEvents[0].get("word") + " : " + 	
	newEvents[0].get("count"));	
} 	
}	
...	
Word keeps : 29	
Word the : 145	
Word doctor : 29	
...	
	
34
© Extenda
Demo – WordCount Esper
35
© Extenda
Summary
Framework/Method Sentences / second
Storm 896
Esper 77399
Disruptor 802568
SingleThread 853242
36
Keep it simple, stupid!
© Extenda
Traffic Jam Tax (Trängselskatt)
37
http://www.theredlinereport.com/2012/05/29/dead-traffic-light-leads-to-beijing-traffic-jam/
© Extenda
It engages people
38
© Extenda
Key word – ”trängselskatt”
39
0
10
20
30
40
50
60
Jan Feb Mar April Maj Jun jul Aug Sep Okt Nov
# artiklar gp.se
# artiklar gp.se
© Extenda
Business Rules
40
© Extenda
Business Rules as BDD
41
Vehicle	
  Billing	
  
	
  
Narrative:	
  	
  
	
  
In	
  order	
  to	
  track	
  the	
  daily	
  toll	
  road	
  billing	
  	
  	
  
As	
  a	
  Vehicle	
  Owner	
  
I	
  want	
  to	
  get	
  notified	
  via	
  SMS	
  in	
  real	
  time	
  of	
  the	
  daily	
  
billing	
  status	
  
© Extenda
Billing
42
Scenario:	
  Billing	
  notification	
  on	
  work	
  days	
  
	
  
Given	
  I	
  am	
  driving	
  a	
  car	
  having	
  <registrationNumber>	
  
When	
  I	
  pass	
  toll	
  road	
  at	
  <date>	
  and	
  <time>	
  	
  	
  
Then	
  I	
  should	
  be	
  notified	
  with	
  a	
  billing	
  statement	
  of	
  <billingamount>	
  SEK	
  for	
  <date>	
  
	
  
Examples:	
  
registrationNumber|date|time|billingamount	
  
PYZ123|2012-­‐09-­‐12|05:59|0	
  
PYZ123|2012-­‐09-­‐12|06:00|8	
  
PYZ123|2012-­‐09-­‐12|06:29|8	
  
PYZ123|2012-­‐09-­‐12|06:30|13	
  
PYZ123|2012-­‐09-­‐12|06:59|13	
  
PYZ123|2012-­‐09-­‐12|07:00|18	
  
PYZ123|2012-­‐09-­‐12|07:59|18	
  
PYZ123|2012-­‐09-­‐12|08:00|13	
  
PYZ123|2012-­‐09-­‐12|08:29|13	
  
PYZ123|2012-­‐09-­‐12|08:30|8	
  
PYZ123|2012-­‐09-­‐12|14:59|8	
  
PYZ123|2012-­‐09-­‐12|15:00|13	
  
PYZ123|2012-­‐09-­‐12|15:29|13	
  
PYZ123|2012-­‐09-­‐12|15:30|18	
  
PYZ123|2012-­‐09-­‐12|16:59|18	
  
PYZ123|2012-­‐09-­‐12|17:00|13	
  
PYZ123|2012-­‐09-­‐12|17:59|13	
  
PYZ123|2012-­‐09-­‐12|18:00|8	
  
PYZ123|2012-­‐09-­‐12|18:29|8	
  
PYZ123|2012-­‐09-­‐12|18:30|0	
  
PYZ123|2012-­‐09-­‐09|07:45|0	
  
PYZ123|2012-­‐07-­‐09|07:45|0
© Extenda
TollBillingStatement
43
@Name(“TollBillingStatment”	
  
select	
  *,	
  BillingService.getBillingAmount(time)	
  as	
  billingAmount	
  from	
  TollEvent	
  
	
  
Static library function call
© Extenda
Static Java library functions
//	
  Import	
  the	
  static	
  helper	
  class	
  BillingService	
  
config.addImport(BillingService.class);	
  
	
  
//	
  Static	
  helper	
  class	
  	
  
public	
  class	
  BillingService	
  {	
  
	
  
public	
  static	
  int	
  getBillingAmount(Calendar	
  time)	
  {	
  
	
  	
  int	
  result	
  =	
  0;	
  
	
  	
  int	
  dayOfWeek	
  =	
  time.get(Calendar.DAY_OF_WEEK);	
  
	
  	
  if	
  (((dayOfWeek	
  >=	
  Calendar.MONDAY)	
  &&	
  (dayOfWeek	
  
	
  Calendar.FRIDAY))	
  &&	
  	
  
	
   	
  (time.get(Calendar.MONTH)	
  !=	
  Calendar.JULY))	
  {	
  
	
  	
  int	
  hour	
  =	
  time.get(Calendar.HOUR_OF_DAY);	
  
	
  	
  int	
  minute	
  =	
  time.get(Calendar.MINUTE);	
  
	
  	
  if	
  (hour	
  <	
  6)	
  {	
  
	
  	
  	
  	
  result	
  =	
  0;	
  
...	
  
}	
  
44
© Extenda
TollEvent
45
	
  
@When("I	
  pass	
  toll	
  road	
  at	
  $date	
  and	
  $time")	
  
@Alias("I	
  pass	
  toll	
  road	
  at	
  <date>	
  and	
  <time>")	
  
public	
  void	
  iPassTollRoadAt(@Named("date")	
  String	
  date,	
  	
  
	
  @Named("time")String	
  time)	
  throws	
  Exception	
  {	
  
	
  	
  	
  
	
  	
  trafficControllerService.setInternalTimer(getCalendar(date,	
  
	
  time).getTimeInMillis());	
  
	
  
	
  	
  TollEvent	
  tollEvent	
  =	
  new	
  TollEvent(registrationNumber,	
  date,	
   	
  getCalendar(date,	
  
time),	
  "1");	
  
	
  
	
  	
  trafficControllerService.logTrafficeEvent(tollEvent);	
  
}	
  
Control the timer at test
@Name(“TollBillingStatment”	
  
select	
  *,	
  BillingService.getBillingAmount(time)	
  as	
  billingAmount	
  from	
  TollEvent	
  
© Extenda
TotalBilling
Scenario: Total Billing notification on work days	
	
Given I am driving a car with PYZ123	
When I pass toll road at 2012-09-12 and 05:50 	
And I pass toll road at 2012-09-12 and 07:10	
And I pass toll road at 2012-09-12 and 08:30	
And I pass toll road at 2012-09-12 and 16:44	
Then I should be notified with a total billing statement of 44 SEK for 2012-09-12	
	
46
© Extenda
TotalBilling
Scenario: Total Billing should not exceed 60 SEK per day 	
	
Given I am driving a car with PYZ123	
When I pass toll road at 2012-09-12 and 05:50 	
And I pass toll road at 2012-09-12 and 07:10	
And I pass toll road at 2012-09-12 and 07:20	
And I pass toll road at 2012-09-12 and 08:30	
And I pass toll road at 2012-09-12 and 16:44	
Then I should be notified with a total billing statement of 60 SEK for 2012-09-12
47
© Extenda
TotalBilling
Scenario: Total Billing should be billed for each day	
	
Given I am driving a vehicle with PYZ123	
When I pass toll road at 2012-09-12 and 05:50 	
And I pass toll road at 2012-09-12 and 07:10	
And I pass toll road at 2012-09-12 and 08:30	
And I pass toll road at 2012-09-12 and 16:44	
Then I should be notified with a total billing statement of 44 SEK for 2012-09-12	
When I pass toll road at 2012-09-13 and 07:10	
Then I should be notified with a total billing statement of 18 SEK for 2012-09-13	
When I pass toll road at 2012-09-14 and 08:30	
And I pass toll road at 2012-09-14 and 16:44	
Then I should be notified with a total billing statement of 26 SEK for 2012-09-14
48
© Extenda
TotalBilling – Named Window
49
create window VehicleBillingWindow.win:time(24 hours) as select date,
registrationNumber, totalBilling from VehicleBilling
Named window is a global data window ≈ SQL Table
Events are automatically removed after 24 hours
© Extenda
TotalBilling – Named Window
50
create window VehicleBillingWindow.win:time(24 hours) as select date,
registrationNumber, totalBilling from VehicleBilling
on TollEvent te	
merge VehicleBillingWindow vbw	
where te.registrationNumber = vbw.registrationNumber and te.date = vbw.date	
when matched and totalBilling < 60 then 	
update set totalBilling = 	
	Math.min(totalBilling + BillingService.getBillingAmount(te.time), 60) 	
when not matched then 	
insert select date, registrationNumber, 	
	BillingService.getBillingAmount(time) as totalBilling
Named window handles mutable events
© Extenda
On-Demand Queries – ”Normal” SQL
public boolean validate(String registrationNumber, String date, int totalBilling) {	
boolean result = false;	
String query = "select * from VehicleBillingWindow where registrationNumber = '" +
	registrationNumber + "' and date = '" + date + "'";	
EPOnDemandQueryResult qryResult = serviceProvider.getEPRuntime().executeQuery(query);	
51
	 		
for (EventBean row : qryResult.getArray()) {	
String _registrationNumber = (String)row.get("registrationNumber");	
String _date = (String)row.get("date");	
if (registrationNumber.equalsIgnoreCase(_registrationNumber) && 	
	(date.equalsIgnoreCase(_date))) {	
int _billing = (Integer)row.get("totalBilling");	
result = _billing == totalBilling;	
break;	
}	
}	
	 		
return result;	
}
© Extenda
Changed Business Requirement
52
Context of 60 minutes
© Extenda
Context Partition
53
Temporal
Every day between
08.00-13.00
Spatial
Outside the city
Less than 60 km
Context
Segmentation Oriented
All Cars Drving > 60 km/h
People older than 65
StateOriented
Weather is sunny
© Extenda
Non-Overlapping vs Overlapping Context
54
create context TollEventHourCtx start TollEvent end after 1 hour;
create TollEventHourCtx initiated TollEvent terminated after 1 hour;
Non-Overlapping (start/end) – 2 context instances
Overlapping (initiated/terminated) – 3 context instances
06:00 07:00 08:00 09:00
© Extenda
Non-Overlapping combined context
55
create context BillingHourRegNumber	
context RegNumberCtx partition by registrationNumber from TollEvent,	
context TollEventHourCtx start TollEvent end after 1 hour;
Non-Overlapping (start/end) – 2 context instances
© Extenda
Calculate at the end of the context
56
@Name("BillingHourRegNumberStmt") 	
@Audit 	
context BillingHourRegNumber 	
	
select date, time, registrationNumber, 	
max(BillingService.getBillingAmount(time)) as
totalBilling 	
from TollEvent 	
	
output when terminated;
© Extenda
Demo - VehicleBillingHour
57
Scenario: Total Billing notification on work days. Passing a toll road within 60 min
should be billed once	
	
Given I am driving my car with PYZ123	
When I pass toll road at 2012-09-12 and 05:50 	
And I pass toll road at 2012-09-12 and 07:40	
And I pass toll road at 2012-09-12 and 08:30	
And I pass toll road at 2012-09-12 and 16:44	
And the clock is 2012-09-12 and 23:44	
Then I should be notified with a total billing statement of 36 SEK for 2012-09-12
© Extenda
Variables
58
create variable int maxPerDay = 60	
	
	
on TollEvent te	
merge VehicleBillingWindow vbw	
where te.registrationNumber = vbw.registrationNumber and te.date = vbw.date	
when matched and totalBilling < maxPerDay then 	
update set totalBilling = 	
	Math.min(totalBilling + BillingService.getBillingAmount(te.time), maxPerDay)	
when not matched then 	
insert select date, registrationNumber, 	
	 	BillingService.getBillingAmount(time) as totalBilling	
serviceProvider.getEPRuntime().setVariable(”maxPerDay”, 100);	
	
create constant variable maxPerDay = 100
© Extenda
Esper – Other things
•  Integration Adapters (In and/or Out) – File, JMS, AMQP, HTTP,
Socket
•  RDBMS support
•  XML (In/Out) & JSON support (Out)
•  Admin API
•  HA Commercial version
•  GPL license
•  …
59
© Extenda
Extenda - Esper
60
© Extenda
Data communication overview
CentralStore
POS CentralofficePOS ServerApplication
Location
Data flow
Reference data, Business configuration
POS transactions, control transactions, accounting and EOD transactions
Mobil POS, SCO, Selfscan,
Kiosk, Self-service
Central
ERP
© Extenda
POSLog – Sale Transaction
public class PosLog {	
	
	private final String retailStoreId;	
	private final String workStationId;	
	private final long sequenceNumber;	
	private final String beginTimeStamp;	
	private final String endTimeStamp;	
	private final String operatorId;	
…	
62
© Extenda
PosLog not stuck in server
Scenario: Track PosLog received by POSServer is sent from POSServer	
	
Given PosLog created for store 001 at workstation 001 by operator 1	
When PosLog sent to PosServer 1 at 2012-09-12 09:00:00	
And PosLog sent from PosServer 1 at 2012-09-12 09:00:59	
Then no alert should be sent	
63
© Extenda
PosLog stuck in server
Scenario: Track PosLog received by POSServer is not sent from POSServer in time	
	
Given PosLog created for store 001 at workstation 001 by operator 1	
When PosLog sent to PosServer 1 at 2012-09-12 09:00:00	
And PosLog sent from PosServer 1 at 2012-09-12 09:02:00	
Then an alert should be sent
	
Scenario: Track PosLog received by POSServer is not sent from POSServer	
	
Given PosLog created for store 001 at workstation 001 by operator 1	
When PosLog sent to PosServer 1 at 2012-09-12 09:00:00	
And the time is 2012-09-12 09:01:01	
Then an alert should be sent
64
© Extenda
PosLog stuck in server
@Audit @Name("MissingPosLogOut") select rstream * 	
from PosLogServerIn.win:time(1 min) posLogServerIn 	
full outer join PosLogServerOut.win:time(1 min) posLogServerOut on
	posLogServerOut.retailStoreId = posLogServerIn.retailStoreId and
	posLogServerOut.workStationId = posLogServerIn.workStationId and
	posLogServerOut.sequenceNumber = posLogServerIn.sequenceNumber 	
where posLogServerOut.retailStoreId is null
65
POS Server
POS transactions, control transactions, accounting and EOD transactions
POS
© Extenda
PosLog Missing
public void update(EventBean[] newEvents, EventBean[] oldEvents) {	
	 		
if (oldEvents == null) {	
// Don't care if PosLogServerIn or PosLogServerOut occured	
return;	
}	
// One min has passed after PosLogServerIn happened for the store	
System.out.println("Missing PosLogServerOut" + 	
	newEvents[0].get ("retailStoreId") + " : " + 	
	newEvents[0].get("workStationId") + 	
	newEvents[0].get("sequenceNumber"));	
}	
66
© Extenda
Aggregation - PosLog generated per
store
select	
  retailStoreId,	
  count(*)	
  as	
  count	
  	
  
from	
  PosLog.win:time(5	
  minutes)	
  	
  
group	
  by	
  retailStoreId	
  	
  
output	
  all	
  every	
  1	
  minutes	
  
67
© Extenda
Fraud – Reuse of login
//Multiple Login at different store during the same day
select	
  p1,	
  p2	
  	
  
from	
  pattern	
  [every	
  p1=PosLog	
  -­‐>	
  p2=PosLog(operatorId=p1.operatorId	
  and	
  
retailStoreId	
  <>	
  p1.retailStoreId)	
  	
  
where	
  timer:within(4	
  hours)]	
  
//Multiple Login at the same store
select	
  p1,	
  p2	
  	
  
from	
  pattern	
  [every	
  p1=PosLog	
  -­‐>	
  p2=PosLog(operatorId=p1.operatorId	
  and	
  
retailStoreId	
  =	
  p1.retailStoreId	
  and	
  workStationId	
  <>	
  p1.workStationId)	
  	
  
where	
  timer:within(5	
  minutes)]	
  
68
© Extenda
Esper - Experience
•  Rather simple model to understand, yet powerful
•  Well documented
•  Solution Patterns and mailing lists
•  Testability
69
© Extenda
Rocksteady – Open Source
70
© Extenda
References
•  Event Processing - Books
•  Event Processing in Action - http://www.manning.com/etzion/
•  The Power of Events: An Introduction to Complex Event Processing in
Distributed Enterprise Systems, Luckham, David. 2002
•  Event Processing: Designing IT Systems for Agile Companies, 1st ed, Chandy,
K. M., and W. R. Schulte. 2009.
•  Event Processing – Sites
•  http://www.ep-ts.com
•  http://www.complexevents.com
•  Esper - http://esper.codehaus.org
•  Storm - http://storm-project.net/
•  https://github.com/nathanmarz/storm
•  http://vimeo.com/40972420
•  Disruptor - http://code.google.com/p/disruptor/
•  http://martinfowler.com/articles/lmax.html
•  Drools - http://www.jboss.org/drools/
71
© Extenda
Questions!
72
© Extenda
Thank you for listening!
peter.norrhall@extenda.se
@peternorrhall
73

More Related Content

What's hot

Kafka summit SF 2019 - the art of the event-streaming app
Kafka summit SF 2019 - the art of the event-streaming appKafka summit SF 2019 - the art of the event-streaming app
Kafka summit SF 2019 - the art of the event-streaming app
Neil Avery
 
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
Srinath Perera
 

What's hot (20)

Event Sourcing in less than 20 minutes - With Akka and Java 8
Event Sourcing in less than 20 minutes - With Akka and Java 8Event Sourcing in less than 20 minutes - With Akka and Java 8
Event Sourcing in less than 20 minutes - With Akka and Java 8
 
Kafka summit SF 2019 - the art of the event-streaming app
Kafka summit SF 2019 - the art of the event-streaming appKafka summit SF 2019 - the art of the event-streaming app
Kafka summit SF 2019 - the art of the event-streaming app
 
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
 
Reactive Design Patterns
Reactive Design PatternsReactive Design Patterns
Reactive Design Patterns
 
Amazon CloudWatch - Observability and Monitoring
Amazon CloudWatch - Observability and MonitoringAmazon CloudWatch - Observability and Monitoring
Amazon CloudWatch - Observability and Monitoring
 
Bank of China (HK) Tech Talk 1: Dive Into Apache Kafka
Bank of China (HK) Tech Talk 1: Dive Into Apache KafkaBank of China (HK) Tech Talk 1: Dive Into Apache Kafka
Bank of China (HK) Tech Talk 1: Dive Into Apache Kafka
 
Distributed Real-Time Stream Processing: Why and How 2.0
Distributed Real-Time Stream Processing:  Why and How 2.0Distributed Real-Time Stream Processing:  Why and How 2.0
Distributed Real-Time Stream Processing: Why and How 2.0
 
Using Apache Pulsar to Provide Real-Time IoT Analytics on the Edge_David
Using Apache Pulsar to Provide Real-Time IoT Analytics on the Edge_DavidUsing Apache Pulsar to Provide Real-Time IoT Analytics on the Edge_David
Using Apache Pulsar to Provide Real-Time IoT Analytics on the Edge_David
 
Event Sourcing - Greg Young
Event Sourcing - Greg YoungEvent Sourcing - Greg Young
Event Sourcing - Greg Young
 
Hard Truths About Streaming and Eventing (Dan Rosanova, Microsoft) Kafka Summ...
Hard Truths About Streaming and Eventing (Dan Rosanova, Microsoft) Kafka Summ...Hard Truths About Streaming and Eventing (Dan Rosanova, Microsoft) Kafka Summ...
Hard Truths About Streaming and Eventing (Dan Rosanova, Microsoft) Kafka Summ...
 
from source to solution - building a system for event-oriented data
from source to solution - building a system for event-oriented datafrom source to solution - building a system for event-oriented data
from source to solution - building a system for event-oriented data
 
How to write your database: the story about Event Store
How to write your database: the story about Event StoreHow to write your database: the story about Event Store
How to write your database: the story about Event Store
 
Introduction to WSO2 Data Analytics Platform
Introduction to  WSO2 Data Analytics PlatformIntroduction to  WSO2 Data Analytics Platform
Introduction to WSO2 Data Analytics Platform
 
Building a system for machine and event-oriented data - Data Day Seattle 2015
Building a system for machine and event-oriented data - Data Day Seattle 2015Building a system for machine and event-oriented data - Data Day Seattle 2015
Building a system for machine and event-oriented data - Data Day Seattle 2015
 
Building a system for machine and event-oriented data - Velocity, Santa Clara...
Building a system for machine and event-oriented data - Velocity, Santa Clara...Building a system for machine and event-oriented data - Velocity, Santa Clara...
Building a system for machine and event-oriented data - Velocity, Santa Clara...
 
Dataflow - A Unified Model for Batch and Streaming Data Processing
Dataflow - A Unified Model for Batch and Streaming Data ProcessingDataflow - A Unified Model for Batch and Streaming Data Processing
Dataflow - A Unified Model for Batch and Streaming Data Processing
 
Spark Summit - Stratio Streaming
Spark Summit - Stratio Streaming Spark Summit - Stratio Streaming
Spark Summit - Stratio Streaming
 
Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...
Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...
Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...
 
Mantis: Netflix's Event Stream Processing System
Mantis: Netflix's Event Stream Processing SystemMantis: Netflix's Event Stream Processing System
Mantis: Netflix's Event Stream Processing System
 
netflix-real-time-data-strata-talk
netflix-real-time-data-strata-talknetflix-real-time-data-strata-talk
netflix-real-time-data-strata-talk
 

Viewers also liked

AGIT 2015 - Hans Viehmann: "Big Data and Smart Cities"
AGIT 2015  - Hans Viehmann: "Big Data and Smart Cities"AGIT 2015  - Hans Viehmann: "Big Data and Smart Cities"
AGIT 2015 - Hans Viehmann: "Big Data and Smart Cities"
jstrobl
 

Viewers also liked (20)

Complex Event Processing: What?, Why?, How?
Complex Event Processing: What?, Why?, How?Complex Event Processing: What?, Why?, How?
Complex Event Processing: What?, Why?, How?
 
CEP: from Esper back to Akka
CEP: from Esper back to AkkaCEP: from Esper back to Akka
CEP: from Esper back to Akka
 
Complex Event Processing - A brief overview
Complex Event Processing - A brief overviewComplex Event Processing - A brief overview
Complex Event Processing - A brief overview
 
Mythbusters: Event Stream Processing v. Complex Event Processing
Mythbusters: Event Stream Processing v. Complex Event ProcessingMythbusters: Event Stream Processing v. Complex Event Processing
Mythbusters: Event Stream Processing v. Complex Event Processing
 
Semantic Complex Event Processing
Semantic Complex Event ProcessingSemantic Complex Event Processing
Semantic Complex Event Processing
 
Complex Event Processing (CEP) for Next-Generation Security Event Management,...
Complex Event Processing (CEP) for Next-Generation Security Event Management,...Complex Event Processing (CEP) for Next-Generation Security Event Management,...
Complex Event Processing (CEP) for Next-Generation Security Event Management,...
 
CEP Overview v1 2 for public use
CEP Overview v1 2 for public useCEP Overview v1 2 for public use
CEP Overview v1 2 for public use
 
Siddhi: A Second Look at Complex Event Processing Implementations
Siddhi: A Second Look at Complex Event Processing ImplementationsSiddhi: A Second Look at Complex Event Processing Implementations
Siddhi: A Second Look at Complex Event Processing Implementations
 
Complex Event Processing with Esper
Complex Event Processing with EsperComplex Event Processing with Esper
Complex Event Processing with Esper
 
Semantic Complex Event Processing at Sem Tech 2010
Semantic Complex Event Processing at Sem Tech 2010Semantic Complex Event Processing at Sem Tech 2010
Semantic Complex Event Processing at Sem Tech 2010
 
Detecting Opportunities and Threats with Complex Event Processing: Case St...
Detecting Opportunities and Threats with Complex Event Processing: Case St...Detecting Opportunities and Threats with Complex Event Processing: Case St...
Detecting Opportunities and Threats with Complex Event Processing: Case St...
 
Complex Event Processing: What?, Why?, How?
Complex Event Processing: What?, Why?, How?Complex Event Processing: What?, Why?, How?
Complex Event Processing: What?, Why?, How?
 
Sybase Complex Event Processing
Sybase Complex Event ProcessingSybase Complex Event Processing
Sybase Complex Event Processing
 
Optimizing Your SOA with Event Processing
Optimizing Your SOA with Event ProcessingOptimizing Your SOA with Event Processing
Optimizing Your SOA with Event Processing
 
TIBCO Business Events Training
TIBCO Business Events TrainingTIBCO Business Events Training
TIBCO Business Events Training
 
Combating Fraud and Intrusion Threats with Event Processing
Combating Fraud and Intrusion Threats with Event ProcessingCombating Fraud and Intrusion Threats with Event Processing
Combating Fraud and Intrusion Threats with Event Processing
 
Tutoriel esper
Tutoriel esperTutoriel esper
Tutoriel esper
 
WSO2Con USA 2017: Scalable Real-time Complex Event Processing at Uber
WSO2Con USA 2017: Scalable Real-time Complex Event Processing at UberWSO2Con USA 2017: Scalable Real-time Complex Event Processing at Uber
WSO2Con USA 2017: Scalable Real-time Complex Event Processing at Uber
 
AGIT 2015 - Hans Viehmann: "Big Data and Smart Cities"
AGIT 2015  - Hans Viehmann: "Big Data and Smart Cities"AGIT 2015  - Hans Viehmann: "Big Data and Smart Cities"
AGIT 2015 - Hans Viehmann: "Big Data and Smart Cities"
 
2015 FOSS4G Track: Spatiotemporal Interface Development: Using Web Technologi...
2015 FOSS4G Track: Spatiotemporal Interface Development: Using Web Technologi...2015 FOSS4G Track: Spatiotemporal Interface Development: Using Web Technologi...
2015 FOSS4G Track: Spatiotemporal Interface Development: Using Web Technologi...
 

Similar to Complex Event Processing in Practice at jDays 2012

WSO2 Product Release Webinar - WSO2 Complex Event Processor
WSO2 Product Release Webinar - WSO2 Complex Event ProcessorWSO2 Product Release Webinar - WSO2 Complex Event Processor
WSO2 Product Release Webinar - WSO2 Complex Event Processor
WSO2
 
Decision CAMP 2014 - Mariano de Maio
Decision CAMP 2014 - Mariano de MaioDecision CAMP 2014 - Mariano de Maio
Decision CAMP 2014 - Mariano de Maio
Decision CAMP
 
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ UberKafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
confluent
 
Flink Forward San Francisco 2018: David Reniz & Dahyr Vergara - "Real-time m...
Flink Forward San Francisco 2018:  David Reniz & Dahyr Vergara - "Real-time m...Flink Forward San Francisco 2018:  David Reniz & Dahyr Vergara - "Real-time m...
Flink Forward San Francisco 2018: David Reniz & Dahyr Vergara - "Real-time m...
Flink Forward
 
MongoDB for Time Series Data: Setting the Stage for Sensor Management
MongoDB for Time Series Data: Setting the Stage for Sensor ManagementMongoDB for Time Series Data: Setting the Stage for Sensor Management
MongoDB for Time Series Data: Setting the Stage for Sensor Management
MongoDB
 
SplunkLive! Dallas Nov 2012 - Metro PCS
SplunkLive! Dallas Nov 2012 - Metro PCSSplunkLive! Dallas Nov 2012 - Metro PCS
SplunkLive! Dallas Nov 2012 - Metro PCS
Splunk
 
Wayne State University & DataStax: World's best data modeling tool for Apache...
Wayne State University & DataStax: World's best data modeling tool for Apache...Wayne State University & DataStax: World's best data modeling tool for Apache...
Wayne State University & DataStax: World's best data modeling tool for Apache...
DataStax Academy
 
Database ,18 Current Issues
Database ,18 Current IssuesDatabase ,18 Current Issues
Database ,18 Current Issues
Ali Usman
 

Similar to Complex Event Processing in Practice at jDays 2012 (20)

WSO2 Product Release Webinar - WSO2 Complex Event Processor
WSO2 Product Release Webinar - WSO2 Complex Event ProcessorWSO2 Product Release Webinar - WSO2 Complex Event Processor
WSO2 Product Release Webinar - WSO2 Complex Event Processor
 
ES and CQRS workshop
ES and CQRS workshopES and CQRS workshop
ES and CQRS workshop
 
Building a system for machine and event-oriented data with Rocana
Building a system for machine and event-oriented data with RocanaBuilding a system for machine and event-oriented data with Rocana
Building a system for machine and event-oriented data with Rocana
 
Decision CAMP 2014 - Mariano de Maio
Decision CAMP 2014 - Mariano de MaioDecision CAMP 2014 - Mariano de Maio
Decision CAMP 2014 - Mariano de Maio
 
Cloud Dataflow - A Unified Model for Batch and Streaming Data Processing
Cloud Dataflow - A Unified Model for Batch and Streaming Data ProcessingCloud Dataflow - A Unified Model for Batch and Streaming Data Processing
Cloud Dataflow - A Unified Model for Batch and Streaming Data Processing
 
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ UberKafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
 
Getting Reactive with CycleJS and XStream
Getting Reactive with CycleJS and XStream Getting Reactive with CycleJS and XStream
Getting Reactive with CycleJS and XStream
 
FOSDEM "XMPP and the IoT" talk by joachim_lindborg 20140202
FOSDEM "XMPP and the IoT" talk by joachim_lindborg 20140202 FOSDEM "XMPP and the IoT" talk by joachim_lindborg 20140202
FOSDEM "XMPP and the IoT" talk by joachim_lindborg 20140202
 
Flink Forward San Francisco 2018: David Reniz & Dahyr Vergara - "Real-time m...
Flink Forward San Francisco 2018:  David Reniz & Dahyr Vergara - "Real-time m...Flink Forward San Francisco 2018:  David Reniz & Dahyr Vergara - "Real-time m...
Flink Forward San Francisco 2018: David Reniz & Dahyr Vergara - "Real-time m...
 
WJUG 210: Event Sourcing z Domain-Driven Design
WJUG 210: Event Sourcing z Domain-Driven DesignWJUG 210: Event Sourcing z Domain-Driven Design
WJUG 210: Event Sourcing z Domain-Driven Design
 
MongoDB for Time Series Data: Setting the Stage for Sensor Management
MongoDB for Time Series Data: Setting the Stage for Sensor ManagementMongoDB for Time Series Data: Setting the Stage for Sensor Management
MongoDB for Time Series Data: Setting the Stage for Sensor Management
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event Sourcing
 
SplunkLive! Dallas Nov 2012 - Metro PCS
SplunkLive! Dallas Nov 2012 - Metro PCSSplunkLive! Dallas Nov 2012 - Metro PCS
SplunkLive! Dallas Nov 2012 - Metro PCS
 
Wayne State University & DataStax: World's best data modeling tool for Apache...
Wayne State University & DataStax: World's best data modeling tool for Apache...Wayne State University & DataStax: World's best data modeling tool for Apache...
Wayne State University & DataStax: World's best data modeling tool for Apache...
 
Database ,18 Current Issues
Database ,18 Current IssuesDatabase ,18 Current Issues
Database ,18 Current Issues
 
Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...
Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...
Enabling Ad-hoc Business Process Adaptations through Event-driven Task Decoup...
 
Learning Accurate Business Process Simulation Models from Event Logs via Auto...
Learning Accurate Business Process Simulation Models from Event Logs via Auto...Learning Accurate Business Process Simulation Models from Event Logs via Auto...
Learning Accurate Business Process Simulation Models from Event Logs via Auto...
 
Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...
Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...
Data to Insight in a Flash: Introduction to Real-Time Analytics with WSO2 Com...
 
Improving the performance of Odoo deployments
Improving the performance of Odoo deploymentsImproving the performance of Odoo deployments
Improving the performance of Odoo deployments
 
Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...
Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...
Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Complex Event Processing in Practice at jDays 2012

  • 1. © Extenda CEP in Practice Peter Norrhall – jDays 2012 peter.norrhall@extenda.se @peternorrhall
  • 2. © Extenda Agenda •  Complex Event Processing (CEP) an Introduction •  Alternative CEP Open Source frameworks •  Esper Essentials •  Extenda’s usage of Esper •  Additional Questions and Summary
  • 3. © Extenda Complex Event Processing (CEP) •  Analyze and react to events 3 CEPEvent Action/Event
  • 4. © Extenda Event Definition •  Event •  Physical Event •  Event in a Programming/Logical Entity •  Non-Event – Absence of an event 4 CEPEvent Action/Event
  • 5. © Extenda Why the word ”Complex”? •  Simple Event Processing •  Acting on single event, filter in the ESP •  Event Stream Processing •  Looking across multiple events •  Complex Event Processing •  Looking across multiple event stream 5
  • 6. © Extenda Complex Event Processing (CEP) •  Analyze and react to events 6 CEPEvent Action/Event BPM/BAM Finance (Trading/Fraud/Risk) Network/App Monitoring Sensor Network App
  • 7. © Extenda CEP – Event Stream Analysis •  High Throughput (1.000-100k events/s) •  Low Latency (ms – seconds) •  Complex Computations •  Detect Patterns Among Events (Event Correlation) •  Filter Events •  Join Event Streams •  Trigger on events and absence of events 7
  • 8. © Extenda EP Network Event Processing - Definitions •  Sensors •  Systems/Applications •  Business Processes •  … •  Dashboards •  Applications •  Data Stores •  Business Processes •  … 8 Event Producers EP Agent Event Consumers EP Agent EP Agent EP Network Statefull|StatelessChannel
  • 9. © Extenda Event Processing Languages •  Rule-oriented •  Production (Drools) •  Active •  Logic •  Imperative (Storm/Disruptor) •  Stream-oriented (Esper) 9
  • 10. © Extenda Storm – Twitter (Backtype) 10 Storm Topology Agent Producer •  Scalable •  Fault-Tolerance •  Garantueed Data Processing •  Easy to Deploy
  • 11. © Extenda BDD – WordCount story Word Count Narrative: In order to find out the most used words As a Twitter Junkie I want to get word count information Scenario: Track word count out of randomly generated sentences Given the sentences: |sentence| |the cow jumped over the moon| |an apple a day keeps the doctor away| |four score and seven years ago| |snow white and the seven dwarfs| |i am at two with nature| When those are randomly selected and split 100 times Then the words should be counted separately 11
  • 12. © Extenda Context •  A context is a named specification of conditions that groups event instances so that they can be processed in a related way. It assigns each event instance to one or more context partitions (windows). A context may have one or more context dimensions and can give rise to one or more context partitions. 12
  • 13. © Extenda Context Partitioning Temporal Every day between 08.00-13.00 Spatial Outside the city Less than 60 km Context Segmentation Oriented All Cars Drving > 60 km/h People older than 65 StateOriented Weather is sunny
  • 14. © Extenda Topology & Context Partitioning 14 Shuffle Grouping Field Grouping TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(1, new KestrelSpout("kestrel.backtype.com", 22133, "sentence_queue", new StringScheme())); builder.setBolt(2, new SplitSentence(), 10) .shuffleGrouping(1); builder.setBolt(3, new WordCount(), 20) .fieldsGrouping(2, new Fields("word"))
  • 15. © Extenda Demo – WordCount Storm 15
  • 16. © Extenda WordCountBolt 16 public static class WordCount extends BaseBasicBolt { Map<String, Integer> counts = new HashMap<String, Integer>(); @Override public void execute(Tuple tuple, BasicOutputCollector collector) String word = tuple.getString(0); Integer count = counts.get(word); if(count==null) count = 0; count++; counts.put(word, count); collector.emit(new Values(word, count)); } @Override public void declareOutputFields(OutputFieldsDeclarer declarer) { declarer.declare(new Fields("word", "count")); } }
  • 19. © Extenda Event Sourcing 19 Event Sourcing ensures that all changes to application state are stored as a sequence of events. Not just can we query these events, •  we can also use the event log to reconstruct past states, •  and as a foundation to automatically adjust the state to cope with retroactive changes. http://martinfowler.com/eaaDev/EventSourcing.html
  • 22. © Extenda Other sample patterns 22
  • 23. © Extenda Demo – WordCount with Disruptor 23
  • 24. © Extenda Comparison Framework/Method Sentences / second Storm 896 Disruptor 802568 24
  • 25. © Extenda Storm/Disruptor •  High Throughput (1.000-100k events/s) •  Low Latency (ms – seconds) •  Complex Computations •  Detect Patterns Among Events (Event Correlation) •  Filter Events •  Join Event Streams •  Trigger on absence of events 25
  • 26. © Extenda Computation (Patterns) •  Business Event Processing (BEP) •  Event Stream Processing (ESP) 26 Aggregator Splitter Enricher Filter Stateless Statefull - Patterns
  • 27. © Extenda Drools – Business Event Processing •  Drools Guvnor – Business Rules Manager •  Drools Expert – Rule Engine •  jBPM – Process / Workflows •  Drools Fusion – Event Processing 27
  • 28. © Extenda Esper – Event Stream Processing •  Pattern Detect – Event Processing Language (EPL) 1.  Filtering 2.  Matching 3.  Derivation 28
  • 29. © Extenda Event Stream vs SQL 29 SQL : select word, count(*) from WordEvent ! group by word! EPL : select word, count(*) ! from WordEvent:win:time(1 min) group by word!
  • 30. © Extenda Esper Building Blocks •  Event •  Statement •  Sending Events •  UpdateListener 30
  • 31. © Extenda (Immutable) Event – POJO or Schema public class WordEvent { private final String word; public WordEvent(String word) { this.word = word; } public String getWord() { return word; } } or create schema WordEvent as (word string) 31
  • 32. © Extenda Statement (Stream) @Name("WordCountBolt”) select word, count(*) as count from WordEvent group by word EPStatement  wordCountStmt  =        epService.getEPAdministrator().createEPL(wordEventStmt);   32
  • 33. © Extenda Sending Events epService.getEPRuntime().sendEvent(new WordEvent(word)); Or Map<String,String> map = new HashMap<String, String>(); map.put("word", word); epService.getEPRuntime().sendEvent(map, "WordEvent"); Or Using EsperIO 33
  • 34. © Extenda UpdateListener epService.getEPAdministrator().getStatement("WordCountBolt").addListener(wordCountListener); public class WordCountListener implements UpdateListener { @Override public void update(EventBean[] newEvents, EventBean[] oldEvents) { System.out.println("Word ” + newEvents[0].get("word") + " : " + newEvents[0].get("count")); } } ... Word keeps : 29 Word the : 145 Word doctor : 29 ... 34
  • 35. © Extenda Demo – WordCount Esper 35
  • 36. © Extenda Summary Framework/Method Sentences / second Storm 896 Esper 77399 Disruptor 802568 SingleThread 853242 36 Keep it simple, stupid!
  • 37. © Extenda Traffic Jam Tax (Trängselskatt) 37 http://www.theredlinereport.com/2012/05/29/dead-traffic-light-leads-to-beijing-traffic-jam/
  • 39. © Extenda Key word – ”trängselskatt” 39 0 10 20 30 40 50 60 Jan Feb Mar April Maj Jun jul Aug Sep Okt Nov # artiklar gp.se # artiklar gp.se
  • 41. © Extenda Business Rules as BDD 41 Vehicle  Billing     Narrative:       In  order  to  track  the  daily  toll  road  billing       As  a  Vehicle  Owner   I  want  to  get  notified  via  SMS  in  real  time  of  the  daily   billing  status  
  • 42. © Extenda Billing 42 Scenario:  Billing  notification  on  work  days     Given  I  am  driving  a  car  having  <registrationNumber>   When  I  pass  toll  road  at  <date>  and  <time>       Then  I  should  be  notified  with  a  billing  statement  of  <billingamount>  SEK  for  <date>     Examples:   registrationNumber|date|time|billingamount   PYZ123|2012-­‐09-­‐12|05:59|0   PYZ123|2012-­‐09-­‐12|06:00|8   PYZ123|2012-­‐09-­‐12|06:29|8   PYZ123|2012-­‐09-­‐12|06:30|13   PYZ123|2012-­‐09-­‐12|06:59|13   PYZ123|2012-­‐09-­‐12|07:00|18   PYZ123|2012-­‐09-­‐12|07:59|18   PYZ123|2012-­‐09-­‐12|08:00|13   PYZ123|2012-­‐09-­‐12|08:29|13   PYZ123|2012-­‐09-­‐12|08:30|8   PYZ123|2012-­‐09-­‐12|14:59|8   PYZ123|2012-­‐09-­‐12|15:00|13   PYZ123|2012-­‐09-­‐12|15:29|13   PYZ123|2012-­‐09-­‐12|15:30|18   PYZ123|2012-­‐09-­‐12|16:59|18   PYZ123|2012-­‐09-­‐12|17:00|13   PYZ123|2012-­‐09-­‐12|17:59|13   PYZ123|2012-­‐09-­‐12|18:00|8   PYZ123|2012-­‐09-­‐12|18:29|8   PYZ123|2012-­‐09-­‐12|18:30|0   PYZ123|2012-­‐09-­‐09|07:45|0   PYZ123|2012-­‐07-­‐09|07:45|0
  • 43. © Extenda TollBillingStatement 43 @Name(“TollBillingStatment”   select  *,  BillingService.getBillingAmount(time)  as  billingAmount  from  TollEvent     Static library function call
  • 44. © Extenda Static Java library functions //  Import  the  static  helper  class  BillingService   config.addImport(BillingService.class);     //  Static  helper  class     public  class  BillingService  {     public  static  int  getBillingAmount(Calendar  time)  {      int  result  =  0;      int  dayOfWeek  =  time.get(Calendar.DAY_OF_WEEK);      if  (((dayOfWeek  >=  Calendar.MONDAY)  &&  (dayOfWeek    Calendar.FRIDAY))  &&        (time.get(Calendar.MONTH)  !=  Calendar.JULY))  {      int  hour  =  time.get(Calendar.HOUR_OF_DAY);      int  minute  =  time.get(Calendar.MINUTE);      if  (hour  <  6)  {          result  =  0;   ...   }   44
  • 45. © Extenda TollEvent 45   @When("I  pass  toll  road  at  $date  and  $time")   @Alias("I  pass  toll  road  at  <date>  and  <time>")   public  void  iPassTollRoadAt(@Named("date")  String  date,      @Named("time")String  time)  throws  Exception  {            trafficControllerService.setInternalTimer(getCalendar(date,    time).getTimeInMillis());        TollEvent  tollEvent  =  new  TollEvent(registrationNumber,  date,    getCalendar(date,   time),  "1");        trafficControllerService.logTrafficeEvent(tollEvent);   }   Control the timer at test @Name(“TollBillingStatment”   select  *,  BillingService.getBillingAmount(time)  as  billingAmount  from  TollEvent  
  • 46. © Extenda TotalBilling Scenario: Total Billing notification on work days Given I am driving a car with PYZ123 When I pass toll road at 2012-09-12 and 05:50 And I pass toll road at 2012-09-12 and 07:10 And I pass toll road at 2012-09-12 and 08:30 And I pass toll road at 2012-09-12 and 16:44 Then I should be notified with a total billing statement of 44 SEK for 2012-09-12 46
  • 47. © Extenda TotalBilling Scenario: Total Billing should not exceed 60 SEK per day Given I am driving a car with PYZ123 When I pass toll road at 2012-09-12 and 05:50 And I pass toll road at 2012-09-12 and 07:10 And I pass toll road at 2012-09-12 and 07:20 And I pass toll road at 2012-09-12 and 08:30 And I pass toll road at 2012-09-12 and 16:44 Then I should be notified with a total billing statement of 60 SEK for 2012-09-12 47
  • 48. © Extenda TotalBilling Scenario: Total Billing should be billed for each day Given I am driving a vehicle with PYZ123 When I pass toll road at 2012-09-12 and 05:50 And I pass toll road at 2012-09-12 and 07:10 And I pass toll road at 2012-09-12 and 08:30 And I pass toll road at 2012-09-12 and 16:44 Then I should be notified with a total billing statement of 44 SEK for 2012-09-12 When I pass toll road at 2012-09-13 and 07:10 Then I should be notified with a total billing statement of 18 SEK for 2012-09-13 When I pass toll road at 2012-09-14 and 08:30 And I pass toll road at 2012-09-14 and 16:44 Then I should be notified with a total billing statement of 26 SEK for 2012-09-14 48
  • 49. © Extenda TotalBilling – Named Window 49 create window VehicleBillingWindow.win:time(24 hours) as select date, registrationNumber, totalBilling from VehicleBilling Named window is a global data window ≈ SQL Table Events are automatically removed after 24 hours
  • 50. © Extenda TotalBilling – Named Window 50 create window VehicleBillingWindow.win:time(24 hours) as select date, registrationNumber, totalBilling from VehicleBilling on TollEvent te merge VehicleBillingWindow vbw where te.registrationNumber = vbw.registrationNumber and te.date = vbw.date when matched and totalBilling < 60 then update set totalBilling = Math.min(totalBilling + BillingService.getBillingAmount(te.time), 60) when not matched then insert select date, registrationNumber, BillingService.getBillingAmount(time) as totalBilling Named window handles mutable events
  • 51. © Extenda On-Demand Queries – ”Normal” SQL public boolean validate(String registrationNumber, String date, int totalBilling) { boolean result = false; String query = "select * from VehicleBillingWindow where registrationNumber = '" + registrationNumber + "' and date = '" + date + "'"; EPOnDemandQueryResult qryResult = serviceProvider.getEPRuntime().executeQuery(query); 51 for (EventBean row : qryResult.getArray()) { String _registrationNumber = (String)row.get("registrationNumber"); String _date = (String)row.get("date"); if (registrationNumber.equalsIgnoreCase(_registrationNumber) && (date.equalsIgnoreCase(_date))) { int _billing = (Integer)row.get("totalBilling"); result = _billing == totalBilling; break; } } return result; }
  • 52. © Extenda Changed Business Requirement 52 Context of 60 minutes
  • 53. © Extenda Context Partition 53 Temporal Every day between 08.00-13.00 Spatial Outside the city Less than 60 km Context Segmentation Oriented All Cars Drving > 60 km/h People older than 65 StateOriented Weather is sunny
  • 54. © Extenda Non-Overlapping vs Overlapping Context 54 create context TollEventHourCtx start TollEvent end after 1 hour; create TollEventHourCtx initiated TollEvent terminated after 1 hour; Non-Overlapping (start/end) – 2 context instances Overlapping (initiated/terminated) – 3 context instances 06:00 07:00 08:00 09:00
  • 55. © Extenda Non-Overlapping combined context 55 create context BillingHourRegNumber context RegNumberCtx partition by registrationNumber from TollEvent, context TollEventHourCtx start TollEvent end after 1 hour; Non-Overlapping (start/end) – 2 context instances
  • 56. © Extenda Calculate at the end of the context 56 @Name("BillingHourRegNumberStmt") @Audit context BillingHourRegNumber select date, time, registrationNumber, max(BillingService.getBillingAmount(time)) as totalBilling from TollEvent output when terminated;
  • 57. © Extenda Demo - VehicleBillingHour 57 Scenario: Total Billing notification on work days. Passing a toll road within 60 min should be billed once Given I am driving my car with PYZ123 When I pass toll road at 2012-09-12 and 05:50 And I pass toll road at 2012-09-12 and 07:40 And I pass toll road at 2012-09-12 and 08:30 And I pass toll road at 2012-09-12 and 16:44 And the clock is 2012-09-12 and 23:44 Then I should be notified with a total billing statement of 36 SEK for 2012-09-12
  • 58. © Extenda Variables 58 create variable int maxPerDay = 60 on TollEvent te merge VehicleBillingWindow vbw where te.registrationNumber = vbw.registrationNumber and te.date = vbw.date when matched and totalBilling < maxPerDay then update set totalBilling = Math.min(totalBilling + BillingService.getBillingAmount(te.time), maxPerDay) when not matched then insert select date, registrationNumber, BillingService.getBillingAmount(time) as totalBilling serviceProvider.getEPRuntime().setVariable(”maxPerDay”, 100); create constant variable maxPerDay = 100
  • 59. © Extenda Esper – Other things •  Integration Adapters (In and/or Out) – File, JMS, AMQP, HTTP, Socket •  RDBMS support •  XML (In/Out) & JSON support (Out) •  Admin API •  HA Commercial version •  GPL license •  … 59
  • 61. © Extenda Data communication overview CentralStore POS CentralofficePOS ServerApplication Location Data flow Reference data, Business configuration POS transactions, control transactions, accounting and EOD transactions Mobil POS, SCO, Selfscan, Kiosk, Self-service Central ERP
  • 62. © Extenda POSLog – Sale Transaction public class PosLog { private final String retailStoreId; private final String workStationId; private final long sequenceNumber; private final String beginTimeStamp; private final String endTimeStamp; private final String operatorId; … 62
  • 63. © Extenda PosLog not stuck in server Scenario: Track PosLog received by POSServer is sent from POSServer Given PosLog created for store 001 at workstation 001 by operator 1 When PosLog sent to PosServer 1 at 2012-09-12 09:00:00 And PosLog sent from PosServer 1 at 2012-09-12 09:00:59 Then no alert should be sent 63
  • 64. © Extenda PosLog stuck in server Scenario: Track PosLog received by POSServer is not sent from POSServer in time Given PosLog created for store 001 at workstation 001 by operator 1 When PosLog sent to PosServer 1 at 2012-09-12 09:00:00 And PosLog sent from PosServer 1 at 2012-09-12 09:02:00 Then an alert should be sent Scenario: Track PosLog received by POSServer is not sent from POSServer Given PosLog created for store 001 at workstation 001 by operator 1 When PosLog sent to PosServer 1 at 2012-09-12 09:00:00 And the time is 2012-09-12 09:01:01 Then an alert should be sent 64
  • 65. © Extenda PosLog stuck in server @Audit @Name("MissingPosLogOut") select rstream * from PosLogServerIn.win:time(1 min) posLogServerIn full outer join PosLogServerOut.win:time(1 min) posLogServerOut on posLogServerOut.retailStoreId = posLogServerIn.retailStoreId and posLogServerOut.workStationId = posLogServerIn.workStationId and posLogServerOut.sequenceNumber = posLogServerIn.sequenceNumber where posLogServerOut.retailStoreId is null 65 POS Server POS transactions, control transactions, accounting and EOD transactions POS
  • 66. © Extenda PosLog Missing public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (oldEvents == null) { // Don't care if PosLogServerIn or PosLogServerOut occured return; } // One min has passed after PosLogServerIn happened for the store System.out.println("Missing PosLogServerOut" + newEvents[0].get ("retailStoreId") + " : " + newEvents[0].get("workStationId") + newEvents[0].get("sequenceNumber")); } 66
  • 67. © Extenda Aggregation - PosLog generated per store select  retailStoreId,  count(*)  as  count     from  PosLog.win:time(5  minutes)     group  by  retailStoreId     output  all  every  1  minutes   67
  • 68. © Extenda Fraud – Reuse of login //Multiple Login at different store during the same day select  p1,  p2     from  pattern  [every  p1=PosLog  -­‐>  p2=PosLog(operatorId=p1.operatorId  and   retailStoreId  <>  p1.retailStoreId)     where  timer:within(4  hours)]   //Multiple Login at the same store select  p1,  p2     from  pattern  [every  p1=PosLog  -­‐>  p2=PosLog(operatorId=p1.operatorId  and   retailStoreId  =  p1.retailStoreId  and  workStationId  <>  p1.workStationId)     where  timer:within(5  minutes)]   68
  • 69. © Extenda Esper - Experience •  Rather simple model to understand, yet powerful •  Well documented •  Solution Patterns and mailing lists •  Testability 69
  • 70. © Extenda Rocksteady – Open Source 70
  • 71. © Extenda References •  Event Processing - Books •  Event Processing in Action - http://www.manning.com/etzion/ •  The Power of Events: An Introduction to Complex Event Processing in Distributed Enterprise Systems, Luckham, David. 2002 •  Event Processing: Designing IT Systems for Agile Companies, 1st ed, Chandy, K. M., and W. R. Schulte. 2009. •  Event Processing – Sites •  http://www.ep-ts.com •  http://www.complexevents.com •  Esper - http://esper.codehaus.org •  Storm - http://storm-project.net/ •  https://github.com/nathanmarz/storm •  http://vimeo.com/40972420 •  Disruptor - http://code.google.com/p/disruptor/ •  http://martinfowler.com/articles/lmax.html •  Drools - http://www.jboss.org/drools/ 71
  • 73. © Extenda Thank you for listening! peter.norrhall@extenda.se @peternorrhall 73

Editor's Notes

  1. Temporaral (Interval/Length/…) – this is one Spatial (Location related) – I read an article So for example when Visa is checking my purchase behaviour. They have a lot parameters when they do a risk analyze if should be able to to the purchase or not in real-time. If my card is used in another part of the world all of a sudden there is an increased risk that something is wrongState-Oriented (ie external Traffic Condition)Segment-Oriented (ie age segmentation)