event driven architectures with camel
DESCRIPTION
The session is about the significance of Camel and using Camel with Event Driven Architectures. It will give an overview of Apache Camel and showcase different types of EDA patterns that can be implemented with Camel. 1. Introduction An introduction to Enterprise Application Integration and Apache Camel Camel as a Chamelion: An introduction to the simplicity of Camel Some interesting components: twitter, aws-sqs, mongodb, web-sockets, camel-extra 2. Event Driven Architectures with Camel What and why of EDA EDA within Camel using SEDA Deployment architectures: Camel as a participant of EDA Actor Model using CamelTRANSCRIPT
![Page 1: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/1.jpg)
1
![Page 2: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/2.jpg)
Event Driven Architectures with
Camel
Gnanaguru Sattanathan
Twitter:@gnanagurus
Website: bushorn.com
Prajod Vettiyattil
Twitter: @prajods
2
![Page 3: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/3.jpg)
What this session is about
Application Integration
Apache Camel
Event Driven Architectures with Camel
3
![Page 4: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/4.jpg)
Application Integration
4
![Page 5: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/5.jpg)
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
![Page 6: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/6.jpg)
The Chameleon
6
![Page 7: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/7.jpg)
Camel is a reptile !
7
![Page 8: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/8.jpg)
The Chameleon
It can change color with the container
Camel
JVM
Camel
Tomcat
Camel
JBoss
Camel
Websphere
Camel
Oracle
Fusion
Camel
Jetty
8
![Page 9: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/9.jpg)
Apache Camel
• Integration framework
• Multiple deployment options
• Feature rich
• Simple to program
• Unique scalability features
• Apache License
9
![Page 10: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/10.jpg)
Apache Camel: Components
• More than 100 readymade components
• Covering
– PaaS & Public Clouds
– Social Networks
– Devices
– Almost all standard protocols
10
![Page 11: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/11.jpg)
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
![Page 12: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/12.jpg)
Coding with Camel
12
![Page 13: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/13.jpg)
Camel – Code your way
JAVA
SPRING
GROOVY
SCALA
Domain Specific Language
(DSL)
13
![Page 14: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/14.jpg)
A simple file integration
File System
Input
Directory
Output
Directory
File
14
![Page 15: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/15.jpg)
Simple file integration:
Sample Code
<route>
<from uri="file://d:\Input"/>
<to uri="file://d:\Output"/>
</route>
15
using Spring XML
![Page 16: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/16.jpg)
Message Broker
( ActiveMQ)
File System – Message Broker
Integration
File System
Input
Directory
Output
Queue
File
16
![Page 17: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/17.jpg)
File System to Message Broker Integration:
Sample Code
<route>
<from uri="file://d:\Input"/>
<to uri="activemq:queue:Output"/>
</route>
17
using Spring XML
![Page 18: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/18.jpg)
Tra
nsfo
rmer
Message Broker
( ActiveMQ)
Adding a simple transformation
File System
Input
Directory
Output
Queue
File
18
![Page 19: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/19.jpg)
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
![Page 20: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/20.jpg)
A simple Twitter application
Message Broker
( ActiveMQ) Twitter.com
Tweets Tweets
Queue
20
Tweets
![Page 21: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/21.jpg)
A simple Twitter application:
Sample Code
<route>
<from uri="twitter://search
?type=direct
&keywords=JUDCON”/>
<to uri="activemq:queue:Output"/>
</route>
21
![Page 22: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/22.jpg)
Event Driven Architectures with
Camel
22
![Page 23: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/23.jpg)
Event Driven Architecture
• EDA • A software architecture pattern • Event: Significant change in state • Parts of the architecture
– Event source – Event channel – Event processor
23
![Page 24: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/24.jpg)
EDA
Source
1
Event
Processor 1
Source
2
Event
Processor 2
Source
3
Event
Processor 3
Source
4
Source
5 Source
6 So
urc
es
C
han
nels
P
rocesso
rs
24
![Page 25: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/25.jpg)
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
![Page 26: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/26.jpg)
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
Sta
ge 1
C
han
nels
usin
g Q
ueu
es
Sta
ge 2
26
![Page 27: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/27.jpg)
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
![Page 28: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/28.jpg)
SEDA with Camel
• SEDA
– Scalability feature in Camel
– Uses thread pools and internal queues
– Enables parallel processing
– Avoids waiting threads
28
![Page 29: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/29.jpg)
Camel with SEDA: comparison
Normalize
Enrich
Split
Route
Waiting thread without SEDA
Th
read 1
Receive Receive
Validate
Normalize
Enrich
Route
Parallel processing with SEDA
Th
read 1
Th
read 2
T
hre
ad 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
![Page 30: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/30.jpg)
Camel as a part of EDA • Camel as
– Event channel
– Event processor
30
Camel
![Page 31: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/31.jpg)
Camel as Event Channel
• SEDA queues
• VM queues
• Multi-threaded flow
• Load balanced flow
• Asynchronous API
31
![Page 32: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/32.jpg)
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
![Page 33: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/33.jpg)
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
![Page 34: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/34.jpg)
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
![Page 35: Event Driven Architectures with Camel](https://reader035.vdocuments.mx/reader035/viewer/2022081801/54b775364a795985568b46c2/html5/thumbnails/35.jpg)
Questions
35
Gnanaguru Sattanathan
Twitter:@gnanagurus
Website: bushorn.com
Prajod Vettiyattil
Twitter: @prajods
Our Open Source Middleware Group on LinkedIn
http://tinyurl.com/be6e93q