Skip to main content
SOA 
Pa1ern: 
Event-­‐Driven 
Dakshitha 
Ratnayake 
Last Updated: Jan. 2014 
Messaging 
Chathura 
Kulasinghe
2 
About 
the 
Presenter(s) 
๏ Dakshitha 
Ratnayake 
๏ Associate 
Technical 
Lead 
– 
Technical 
Sales 
๏ Experience 
with 
Java/J2EE 
technologies 
in 
the 
fields 
of 
health-­‐ 
care 
informaOon 
systems 
and 
content 
management 
systems 
for 
telecommunicaOons 
providers 
prior 
to 
her 
employment 
at 
WSO2. 
๏ Prior 
to 
joining 
the 
SoluOons 
Architecture 
team 
she 
worked 
with 
the 
WSO2 
Developer 
Studio 
team. 
๏ Chathura 
Kulasinghe 
๏ SoluOons 
Engineer 
๏ Experience 
with 
Java/J2EE, 
.net 
based 
enterprise 
(banking) 
applicaOons 
design 
and 
development 
prior 
to 
his 
employment 
at 
WSO2. 
๏ UX 
design 
and 
iOS 
app 
development. 
๏ He 
has 
also 
contributed 
to 
the 
developments 
of 
the 
WSO2 
App 
Factory.
3 
About 
WSO2 
๏ Global 
enterprise, 
founded 
in 
2005 
by 
acknowledged 
leaders 
in 
XML, 
web 
services 
technologies, 
standards 
and 
open 
source 
๏ Provides 
only 
open 
source 
plaorm-­‐as-­‐a-­‐service 
for 
private, 
public 
and 
hybrid 
cloud 
deployments 
๏ All 
WSO2 
products 
are 
100% 
open 
source 
and 
released 
under 
the 
Apache 
License 
Version 
2.0. 
๏ Is 
an 
AcOve 
Member 
of 
OASIS, 
Cloud 
Security 
Alliance, 
OSGi 
Alliance, 
AMQP 
Working 
Group, 
OpenID 
FoundaOon 
and 
W3C. 
๏ Driven 
by 
InnovaOon 
๏ Launched 
first 
open 
source 
API 
Management 
soluOon 
in 
2012 
๏ Launched 
App 
Factory 
in 
2Q 
2013 
๏ Launched 
Enterprise 
Store 
and 
first 
open 
source 
Mobile 
soluOon 
in 
4Q 
2013
4 
What 
WSO2 
delivers
Overall 
PresentaOon 
Goals 
๏ Understand 
Event-­‐Driven 
Architecture 
(EDA) 
and 
Messaging 
๏ Understand 
the 
benefits 
of 
EDA 
and 
how 
it 
fits 
into 
SOA 
๏ How 
CEP 
extends 
EDA 
๏ Introduce 
how 
EDA 
and 
CEP 
concepts 
are 
supported 
through 
the 
WSO2 
plaorm 
๏ DemonstraOon 
of 
an 
event-­‐driven 
messaging 
scenario
What 
is 
an 
Event? 
6 
Image 
Source 
-­‐ 
h7p://www.flamemedia.com.vn/images/ 
slide/?cke?ng-­‐header.jpg
DefiniOon 
of 
an 
Event 
in 
Event 
Architecture 
๏ A 
set 
of 
informaOon 
(properOes) 
about 
an 
object 
(or 
objects) 
at 
a 
given 
Ome 
๏ Usually 
encapsulated 
as 
a 
message 
7
Event 
CharacterisOcs 
๏ Represents 
a 
change 
in 
state 
๏ Self-­‐contained 
๏ A 
pure 
and 
complete 
representaOon 
of 
a 
specific 
event 
๏ No 
references 
to 
other 
data 
sources 
๏ Reduces 
dependencies, 
loosens 
coupling 
๏ Uniquely 
IdenOfiable 
๏ Enables 
idempotent 
handling 
of 
events 
๏ Allows 
correlaOon 
with 
related 
events 
๏ Time 
relevant, 
not 
Ome 
sensiOve 
๏ Sourced 
using 
messaging 
๏ Observable 
๏ Published 
events 
can 
be 
observed 
by 
mulOple 
subscribers 
๏ Event 
stream 
processing 
8
Event 
Driven 
Architecture 
(EDA) 
๏ A 
method 
of 
building 
enterprise 
systems 
in 
which 
events 
flow 
between 
decoupled 
components 
and 
services 
๏ A 
maintainable, 
sustainable, 
and 
extensible 
model 
for 
building 
complex, 
distributed 
applicaOons 
๏ Well 
suited 
for 
asynchronous, 
unpredictable 
environments 
9
Event 
Driven 
Architecture
Publish 
/ 
Subscribe 
๏ A 
distribuOon 
model 
for 
events 
๏ Events 
are 
Oed 
to 
some 
logical 
model 
-­‐ 
“Event 
Streams” 
/ 
“Topic” 
(the 
most 
used 
model) 
๏ A 
Topic 
is 
a 
tree-­‐based 
model 
or 
namespace 
that 
makes 
it 
easy 
to 
organize 
Events 
11
Event 
Producers 
and 
Consumers 
Event 
Producers/Generators/ 
Sources 
๏ Publish 
messages 
represenOng 
an 
event 
๏ Olen 
oblivious 
to 
the 
consequences 
of 
the 
generated 
event 
Event 
Consumers/Subscribers/ 
Sinks 
๏ Subscribe 
to 
events 
by 
topic/type/ 
selector 
๏ Handle 
events 
asynchronously 
๏ No 
performance 
penalty 
for 
addiOonal 
consumers 
12
Why 
is 
EDA 
a1racOve? 
๏ Incredibly 
loosely 
coupled 
๏ The 
sensor 
doesn’t 
need 
to 
be 
aware 
of 
the 
actuator 
๏ The 
actuator 
doesn’t 
need 
to 
be 
aware 
of 
the 
sensor 
๏ Events 
can 
be 
re-­‐distributed 
๏ The 
topology 
can 
change 
๏ New 
actuators 
or 
sensors 
can 
be 
added 
seamlessly 
๏ Topic 
or 
Event 
Streams 
give 
the 
ability 
to 
self-­‐organize
Examples: 
Event 
Based 
Models 
๏ Publisher 
updates 
Facebook 
status 
-­‐> 
Subscribers’ 
Facebook 
walls 
display 
Publisher’s 
status 
update 
๏ Same 
goes 
with 
Twi1er, 
Instagram 
etc. 
๏ Older 
models: 
nntp, 
irc, 
mailing 
lists
How 
is 
EDA 
different 
from 
SOA? 
Service 
Oriented 
Architecture 
๏ ApplicaOons 
are 
composed 
at 
design-­‐Ome 
๏ Linear 
flow 
between 
services 
๏ Predictable 
behavior 
๏ Request/Response 
is 
common, 
overused 
Event 
Driven 
Architecture 
๏ ApplicaOons 
are 
composed 
at 
run-­‐ 
Ome 
๏ Asynchronous 
components 
๏ ReacOve 
behavior 
๏ Natural 
fit 
for 
distributed 
systems 
15 
Another Architecture??!!? 
EDA Complements SOA!
SOA 
Pa1ern: 
Event-­‐Driven 
Messaging 
EDA 
Complements 
SOA! 
๏ Problem: 
How 
can 
service 
consumers 
be 
automa?cally 
no?fied 
of 
run?me 
service 
events? 
๏ SoluBon: 
The 
consumer 
establishes 
itself 
as 
a 
subscriber 
of 
the 
service. 
The 
service, 
in 
turn, 
automa?cally 
issues 
no?fica?ons 
of 
relevant 
events 
to 
this 
and 
any 
of 
its 
subscribers. 
๏ ApplicaBon: 
A 
messaging 
framework 
is 
implemented 
capable 
of 
suppor?ng 
the 
publish-­‐and-­‐subscribe 
MEP 
and 
associated 
complex 
event 
processing 
and 
tracking. 
16
Event 
Transports 
๏ JMS 
๏ WS-­‐EvenOng 
/ 
SOAP 
๏ Stomp/…/… 
๏ AMQP 
๏ XMPP 
๏ MQTT 
17
EDA 
with 
SOA 
Event 
Generator 
Event 
Generator 
Message 
Broker 
Event 
Consumer 
Event 
Consumer 
Event 
Consumer 
BAM 
Event 
Bus 
/ 
Channel 
CEP
EDA 
+ 
SOA 
with 
WSO2 
Event 
Generator 
Event 
Generator 
Message 
Broker 
Event 
Consumer 
Event 
Consumer 
Event 
Consumer 
BAM 
Event 
Bus 
/ 
Channel 
CEP
Event 
Bus 
/ 
Channel 
๏ Usually 
an 
Enterprise 
Service 
Bus 
๏ Emi1ers 
and 
consumers 
connected 
through 
the 
bus 
๏ Different 
interfaces 
/ 
message 
formats 
๏ GeneraOng 
events 
from 
the 
bus 
itself 
๏ IntegraOng 
non-­‐event 
based 
systems 
๏ WSO2 
ESB 
๏ WS-­‐Even?ng 
based 
interac?ons 
/ 
integra?ons 
๏ Transforming 
to 
and 
from 
WS-­‐Events 
and 
general 
triggers 
๏ Reliable 
delivery 
with 
a 
JMS 
broker
Pub/Sub 
with 
WS-­‐EvenOng 
21
Pub/Sub 
with 
JMS 
22
Message 
Broker 
๏ SupporOng 
different 
messaging 
pa1erns 
๏ Queue 
based 
and 
pub/sub 
๏ Reliable 
delivery 
of 
messages/events 
๏ WSO2 
Message 
Broker 
๏ Support 
for 
JMS 
v1.0 
and 
v1.1 
API 
and 
Advanced 
Message 
Queuing 
Protocol, 
the 
only 
industry 
standard 
protocol 
for 
interoperable 
reliable 
messaging 
๏ Interoperability 
with 
many 
languages 
/ 
plaTorms 
via 
AMQP 
clients 
for 
Java, 
.Net, 
C, 
C++, 
PHP, 
Ruby 
and 
more 
๏ Support 
for 
in 
memory 
message 
store 
to 
improve 
performance. 
๏ Scalable, 
distributed 
message 
storage 
based 
on 
Cassandra 
๏ Distributed 
queuing
Pub/Sub 
with 
WSO2 
ESB 
and 
WSO2 
MB 
24
Event 
Processing 
๏ Simple 
Event 
Processing 
๏ AcOng 
on 
single 
events 
๏ e.g. 
a 
<filter> 
in 
the 
ESB 
or 
Is 
this 
a 
gold 
or 
plaOnum 
customer? 
๏ Event 
Stream 
Processing 
๏ Looking 
across 
mulOple 
events 
๏ Finding 
pa1erns 
– 
e.g. 
the 
CPU 
uOlizaOon 
has 
been 
more 
than 
90% 
for 
the 
last 
10 
minutes 
๏ Complex 
Event 
Processing 
๏ Looking 
across 
mulOple 
event 
streams 
๏ e.g 
There 
has 
been 
a 
significant 
increase 
in 
overall 
trading 
acOvity 
AND 
the 
average 
price 
of 
commodiOes 
has 
fallen 
2% 
in 
the 
last 
4 
hours
Business 
AcOvity 
Monitoring 
๏ Monitoring 
end-­‐to-­‐end 
business 
message 
flow 
๏ IdenOfying/collecOng/tracing 
business 
transacOons 
๏ WSO2 
BAM 
๏ Scalable 
analy?cs 
using 
Hadoop 
๏ Scalable 
data 
storage 
model, 
Cassandra 
๏ Flexible 
deployment 
model 
(external 
Hadoop 
cluster 
and 
external 
Cassandra 
ring) 
๏ Intui?ve 
and 
powerful 
dashboards
WSO2 
Business 
AcOvity 
Monitor
Complex 
Event 
Processing 
๏ Reading 
mulOple 
conOnuous 
event 
streams 
real-­‐Ome 
๏ IdenOfy 
different 
pa1erns 
from 
these 
events 
๏ WSO2 
CEP 
๏ Extremely 
High 
Performant 
Processing 
Engine 
๏ Processes 
more 
than 
2.5M 
events/sec 
on 
single 
server 
commodity 
hardware. 
๏ Powered 
by 
WSO2 
Siddhi 
Query 
Language. 
๏ Filter 
events 
by 
condi?ons. 
๏ Join 
event 
streams 
and 
create 
new 
streams. 
๏ Execute 
temporal 
queries 
using 
various 
windows. 
๏ Detect 
and 
respond 
to 
various 
event 
pa7erns 
and 
sequences. 
๏ Process 
historical 
data 
in 
RDBMS 
in 
real-­‐?me.
29 
WSO2 
Complex 
Event 
Processor
Demo 
Outline 
-­‐ Publisher-­‐Subscriber 
with 
WSO2 
ESB 
-­‐ WSO2 
ESB 
as 
the 
Event 
Publisher 
-­‐ Topic 
-­‐ Web 
service 
instances 
as 
the 
Subscribers 
-­‐ Complex 
Event 
Processing 
with 
WSO2 
CEP 
-­‐ Delayed 
flights 
detecOon
WSO2 
ESB 
as 
Event 
Publisher 
Client 
ApplicaOon 
WSO2 
ESB 
topic 
Web 
Service 
1 
Web 
Service 
2
WSO2 
ESB 
as 
Event 
Publisher 
WSO2 
ESB 
Topic 
Main 
Sequence 
Subscribers 
Subscriber 
01 
Subscriber 
01 
Event 
Mediator
Demo
Delayed 
Flight 
AlerBng 
System 
External 
Systems/Devices 
Flights 
informaOon 
system 
Processing 
WSO2 
CEP 
events 
when 
a 
delayed 
flight 
is 
detected. 
Data 
Stream
JMS 
Consumer 
Demo 
Sample 
Setup 
Data 
Stream 
publisher 
Processing 
WSO2 
CEP 
events 
when 
a 
delayed 
flight 
is 
detected. 
JMS 
Queue 
Data 
Stream
Complex 
Event 
Processing 
flightStatsStream 
Flight 
01 
-­‐ 
Delayed 
Flight 
02 
-­‐ 
On-­‐Ome 
Flight 
03 
-­‐ 
On-­‐Ome 
WSO2 
CEP 
Detects 
one 
Delayed 
Flights 
delayedFlightStream 
Flight 
01 
(InformaOon) 
from 
flightStatsStream 
[status 
!= 
'On-­‐Time'] 
select 
flightName, 
flightId, 
flightType, 
arrivalTime, 
trackNo 
insert 
into 
delayedFlightStream
Demo
Summary 
38 
๏ Event 
Driven 
Architecture 
is 
a 
good 
thing 
๏ Adding 
Complex 
Event 
Processing 
can 
significantly 
add 
value 
๏ WSO2 
Supports 
Event 
Driven 
Architecture 
and 
Messaging 
through 
various 
products. 
i.e. 
ESB, 
Message 
Broker, 
Business 
AcOvity 
Monitor 
and 
Complex 
Event 
Processor
Resources 
๏ h1p://rangasiriwardena.blogspot.com/2014/03/ 
pubsub-­‐with-­‐wso2-­‐mb-­‐and-­‐wso2-­‐esb-­‐using.html 
๏ h1p://soapa1erns.org/design_pa1erns/ 
event_driven_messaging 
๏ h1ps://docs.wso2.com/display/ESB481/Working+with 
+Topics+and+Events 
๏ h1p://www.informit.com/arOcles/arOcle.aspx? 
p=1577450
40 
Business 
Model
Contact 
us 
!