event driven architectures - jbosstomcat camel jboss camel websphere camel oracle fusion camel jetty...

35
1

Upload: others

Post on 19-Jan-2020

28 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

1

Page 2: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Event Driven Architectures with

Camel

Gnanaguru Sattanathan Twitter:@gnanagurus

Website: bushorn.com

Prajod Vettiyattil Twitter: @prajods

2

Page 3: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

What this session is about

v Application Integration

v Apache Camel

v Event Driven Architectures with Camel

3

Page 4: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Application Integration

4

Page 5: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

The Chameleon

6

Page 7: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Camel is a reptile !

7

Page 8: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

The Chameleon It can change color with the container J

Camel

JVM

Camel

Tomcat

Camel

JBoss

Camel

Websphere

Camel

Oracle Fusion

Camel

Jetty

8

Page 9: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Apache Camel

•  Integration framework •  Multiple deployment options •  Feature rich •  Simple to program •  Unique scalability features •  Apache License

9

Page 10: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Coding with Camel

12

Page 13: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Camel – Code your way

JAVA

SPRING

GROOVY

SCALA

Domain Specific Language (DSL)

13

Page 14: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

A simple file integration

File System

Input Directory

Output Directory

File

14

Page 15: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Message Broker ( ActiveMQ)

File System – Message Broker Integration

File System

Input Directory

Output Queue

File

16

Page 17: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Tran

sfor

mer

Message Broker ( ActiveMQ)

Adding a simple transformation

File System

Input Directory

Output Queue

File

18

Page 19: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

A simple Twitter application

Message Broker ( ActiveMQ)

Twitter.com

Tweets Tweets Queue

20

Tweets

Page 21: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Event Driven Architectures with

Camel

22

Page 23: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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

Page 25: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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

Page 27: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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

Page 30: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Camel as a part of EDA •  Camel as

–  Event channel –  Event processor

30

Camel

Page 31: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Camel as Event Channel •  SEDA queues •  VM queues •  Multi-threaded flow •  Load balanced flow •  Asynchronous API

31

Page 32: Event Driven Architectures - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

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 - JBossTomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8 . Apache Camel • Integration framework • Multiple deployment options •

Questions

35

Gnanaguru Sattanathan Twitter:@gnanagurus

Website: bushorn.com

Prajod Vettiyattil Twitter: @prajods

Our Open Source Middleware Group on LinkedIn http://tinyurl.com/be6e93q