event driven architecture with apache camel

35
1

Upload: prajods

Post on 27-Jun-2015

806 views

Category:

Technology


3 download

DESCRIPTION

This presentation describes Event Driven Architecture(EDA) support in Camel, and scalability features like SEDA and Akka support in Camel.It starts with an overview of Camel and introduces its simple syntax

TRANSCRIPT

Page 1: Event Driven Architecture with Apache Camel

1

Page 2: Event Driven Architecture with Apache Camel

Event Driven Architectures with

Camel

Gnanaguru Sattanathan

Twitter:@gnanagurus

Website: bushorn.com

Prajod Vettiyattil

Twitter: @prajods

2

Page 3: Event Driven Architecture with Apache Camel

What this session is about

Application Integration

Apache Camel

Event Driven Architectures with Camel

3

Page 4: Event Driven Architecture with Apache Camel

Application Integration

4

Page 5: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

The Chameleon

6

Page 7: Event Driven Architecture with Apache Camel

Camel is a reptile !

7

Page 8: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

Apache Camel

• Integration framework

• Multiple deployment options

• Feature rich

• Simple to program

• Unique scalability features

• Apache License

9

Page 10: Event Driven Architecture with Apache Camel

Apache Camel: Components

• More than 100 readymade components

• Covering

– PaaS & Public Clouds

– Social Networks

– Devices

– Almost all standard protocols

10

Page 11: Event Driven Architecture with Apache Camel

Apache Camel: Components

AWS HDFS

FILE JDBC

AMQP

JMS

MQTT

MongoDB

NETTY

RMI

WebSockets Zoo Keeper

JGroups

ActiveMQ

NMR Smooks

Esper

XSLT

Velocity

Streams

Twitter

SSH

SQL

TCP

SMTP SMPP SOLR

UDP

XQuery

SIP

SFTP

Cache Hazelcast

11

Page 12: Event Driven Architecture with Apache Camel

Coding with Camel

12

Page 13: Event Driven Architecture with Apache Camel

Camel – Code your way

JAVA

SPRING

GROOVY

SCALA

Domain Specific Language

(DSL)

13

Page 14: Event Driven Architecture with Apache Camel

A simple file integration

File System

Input

Directory

Output

Directory

File

14

Page 15: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

Message Broker

( ActiveMQ)

File System – Message Broker

Integration

File System

Input

Directory

Output

Queue

File

16

Page 17: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

Tra

nsfo

rme

r

Message Broker

( ActiveMQ)

Adding a simple transformation

File System

Input

Directory

Output

Queue

File

18

Page 19: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

A simple Twitter application

Message Broker

( ActiveMQ) Twitter.com

Tweets Tweets

Queue

20

Tweets

Page 21: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

Event Driven Architectures with

Camel

22

Page 23: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

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

ha

nn

els

P

roc

es

so

rs

24

Page 25: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

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

ha

nn

els

us

ing

Qu

eu

es

S

tag

e 2

26

Page 27: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

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 Architecture with Apache Camel

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

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 Architecture with Apache Camel

Camel as a part of EDA • Camel as

– Event channel

– Event processor

30

Camel

Page 31: Event Driven Architecture with Apache Camel

Camel as Event Channel

• SEDA queues

• VM queues

• Multi-threaded flow

• Load balanced flow

• Asynchronous API

31

Page 32: Event Driven Architecture with Apache Camel

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 Architecture with Apache Camel

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 Architecture with Apache Camel

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 Architecture with Apache Camel

Questions

35

Gnanaguru Sattanathan

Twitter:@gnanagurus

Website: bushorn.com

Prajod Vettiyattil

Twitter: @prajods

Our Open Source Middleware Group on LinkedIn

http://tinyurl.com/be6e93q