View
44
Download
0
Category
Preview:
Citation preview
1
Event Driven Architectures with
Camel
Gnanaguru Sattanathan Twitter:@gnanagurus
Website: bushorn.com
Prajod Vettiyattil Twitter: @prajods
2
What this session is about
v Application Integration
v Apache Camel
v Event Driven Architectures with Camel
3
Application Integration
4
Integration
Middleware
JMS, RMI,
JDBC, FTP,
SNMP, TCP
https, SFTP, SNMP,
TCP, CORBA
1. Enterprise Service Bus 2. Integration Framework
1. Validate, Enrich, Route, Transform
2. Diverse protocol support
5
The Chameleon
6
Camel is a reptile !
7
The Chameleon It can change color with the container J
Camel
JVM
Camel
Tomcat
Camel
JBoss
Camel
Websphere
Camel
Oracle Fusion
Camel
Jetty
8
Apache Camel
• Integration framework • Multiple deployment options • Feature rich • Simple to program • Unique scalability features • Apache License
9
Apache Camel: Components
• More than 100 readymade components • Covering
– PaaS & Public Clouds – Social Networks – Devices – Almost all standard protocols
10
Apache Camel: Components AWS HDFS
FILE JDBC
AMQP
JMS
MQTT
MongoDB
NETTY
RMI
WebSockets Zoo Keeper
JGroups
ActiveMQ
NMR Smooks
Esper
XSLT
Velocity
Streams
SSH
SQL
TCP
SMTP SMPP SOLR
UDP
XQuery
SIP
SFTP
Cache Hazelcast
11
Coding with Camel
12
Camel – Code your way
JAVA
SPRING
GROOVY
SCALA
Domain Specific Language (DSL)
13
A simple file integration
File System
Input Directory
Output Directory
File
14
Simple file integration: Sample Code
<route> <from uri="file://d:\Input"/> <to uri="file://d:\Output"/>
</route>
15
using Spring XML
Message Broker ( ActiveMQ)
File System – Message Broker Integration
File System
Input Directory
Output Queue
File
16
File System to Message Broker Integration: Sample Code
<route> <from uri="file://d:\Input"/> <to uri="activemq:queue:Output"/>
</route>
17
using Spring XML
Tran
sfor
mer
Message Broker ( ActiveMQ)
Adding a simple transformation
File System
Input Directory
Output Queue
File
18
A simple transformation: Sample Code
<route> <from uri="file://d:\Input"/> <to uri="xslt:file://d:\transform.xsl"/> <to uri="activemq:queue:Output"/>
</route>
19
using Spring XML
A simple Twitter application
Message Broker ( ActiveMQ)
Twitter.com
Tweets Tweets Queue
20
Tweets
A simple Twitter application: Sample Code
<route> <from uri="twitter://search
?type=direct &keywords=JUDCON”/>
<to uri="activemq:queue:Output"/> </route>
21
Event Driven Architectures with
Camel
22
Event Driven Architecture
• EDA • A software architecture pattern • Event: Significant change in state • Parts of the architecture
– Event source – Event channel – Event processor
23
EDA Source
1
Event Processor 1
Source 2
Event Processor 2
Source 3
Event Processor 3
Source 4
Source 5
Source 6 So
urce
s C
hann
els
Proc
esso
rs
24
Staged Event Driven Architecture(SEDA)
• EDA – Direct and tight coupling of sources and
processors – Event processor may get swamped with events
• Reduces performance • Possible loss of messages
• SEDA – EDA decomposed into stages and connected with
queues
25
SEDA: one view Source
1
Event Processor 1
Source 2
Event Processor 2
Source 3
Event Processor 3
Source 4
Source 5
Source 6
Channels
Stag
e 1
Cha
nnel
s us
ing
Que
ues
Stag
e 2
26
SEDA: another view
Source 1
Source 2
Queue Processor 1
Processor 2
Processor 3 Queue
Queue
Stage 2 Channels using Queues
Stage 1 Channels using Queues
Stage 3
27
SEDA with Camel
• SEDA – Scalability feature in Camel – Uses thread pools and internal queues – Enables parallel processing – Avoids waiting threads
28
Camel with SEDA: comparison
Normalize
Enrich
Split
Route
Waiting thread without SEDA
Thre
ad 1
Receive Receive
Validate
Normalize
Enrich
Route
Parallel processing with SEDA
Thre
ad 1
Thre
ad 2
Th
read
3
SEDA Queue 1
SEDA Queue 2
Split
29
Validate
• Impact – significant reduction in thread
consumption
• For 100 concurrent requests – Without SEDA: 100 threads; With SEDA: 30 threads
Camel as a part of EDA • Camel as
– Event channel – Event processor
30
Camel
Camel as Event Channel • SEDA queues • VM queues • Multi-threaded flow • Load balanced flow • Asynchronous API
31
Camel as Event Processor • Not ideal as the final Event Processor • Can be used as an intermediate Event processor • Routing based on events • Transformation of events • Combining simple events • Event auditing, logging
32
Camel and the Actor Model with Akka
• Actor Model – Actors
• Similar to objects, many other features • Mailbox, behavior/s, internal state
– No shared state – Messages between actors – Locking and Threads are abstracted – Each actor instance runs in its own thread
• Akka-Camel – Integrate Akka to other applications – Two way: Akka to Camel and Camel to Akka
33
Actor
Mailbox State
Behavior
Summary • Camel
– Integration Framework – Simplicity and flexibility – Components
• EDA with Camel – SEDA – SEDA within Camel – Camel as part of SEDA
• Akka and Camel for EDA
34
Questions
35
Gnanaguru Sattanathan Twitter:@gnanagurus
Website: bushorn.com
Prajod Vettiyattil Twitter: @prajods
Our Open Source Middleware Group on LinkedIn http://tinyurl.com/be6e93q
Recommended