Event Driven Architectures with Camel


Published on

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 Camel

Event Driven Architectures with Camel

  1. 1. 1
  2. 2. Event Driven Architectures with CamelGnanaguru Sattanathan Prajod Vettiyattil Twitter:@gnanagurus Twitter: @prajodsWebsite: bushorn.com2
  3. 3. What this session is aboutApplication IntegrationApache CamelEvent Driven Architectures with Camel3
  4. 4. Application Integration4
  5. 5. Integration JMS, 1. Validate, Enrich, Route, RMI, Transform JDBC, 2. Diverse protocol support FTP, SNMP, TCP Middleware https, SFTP, SNMP, 1. Enterprise Service Bus TCP, CORBA 2. Integration Framework5
  6. 6. The Chameleon6
  7. 7. Camel is a reptile !7
  8. 8. The ChameleonIt can change color with the container Camel Camel Camel Camel Camel Camel OracleJVM Tomcat JBoss Websphere Jetty Fusion8
  9. 9. Apache Camel• Integration framework• Multiple deployment options• Feature rich• Simple to program• Unique scalability features• Apache License9
  10. 10. Apache Camel: Components• More than 100 readymade components• Covering – PaaS & Public Clouds – Social Networks – Devices – Almost all standard protocols10
  11. 11. Apache Camel: Components AWS HDFS MongoDB ActiveMQ TwitterFILE JDBC JMS SFTP Streams JGroupsAMQP MQTT NETTY SQL SIP UDPCache Esper Hazelcast Zoo Keeper WebSocketsSMTP SSH SMPP SOLR RMI Velocity Smooks XQuery XSLT NMR TCP 11
  12. 12. Coding with Camel12
  13. 13. Camel – Code your way JAVA Domain Specific Language SPRING (DSL) GROOVY SCALA13
  14. 14. A simple file integration File File System Input Output Directory Directory14
  15. 15. Simple file integration: Sample Code <route> <from uri="file://d:Input"/> <to uri="file://d:Output"/> </route> using Spring XML15
  16. 16. File System – Message Broker Integration File File System Message Broker ( ActiveMQ) Input Output Directory Queue16
  17. 17. File System to Message Broker Integration: Sample Code<route> <from uri="file://d:Input"/> <to uri="activemq:queue:Output"/></route> using Spring XML 17
  18. 18. Adding a simple transformation File Transformer File System Message Broker ( ActiveMQ) Input Output Directory Queue18
  19. 19. A simple transformation: Sample Code<route> <from uri="file://d:Input"/> <to uri="xslt:file://d:transform.xsl"/> <to uri="activemq:queue:Output"/></route> using Spring XML 19
  20. 20. A simple Twitter application Twitter.com Message Broker ( ActiveMQ) Tweets Tweets Tweets Queue20
  21. 21. A simple Twitter application: Sample Code<route> <from uri="twitter://search ?type=direct &keywords=JUDCON”/> <to uri="activemq:queue:Output"/></route> 21
  22. 22. Event Driven Architectures with Camel22
  23. 23. Event Driven Architecture• EDA• A software architecture pattern• Event: Significant change in state• Parts of the architecture – Event source – Event channel – Event processor23
  24. 24. EDASources Source Source Source Source Source Source 1 2 3 4 5 6ChannelsProcessors Event Event Event Processor 1 Processor 2 Processor 3 24
  25. 25. StagedEvent 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 queues25
  26. 26. SEDA: one viewStage 1 Source Source Source Source Source Source 1 2 3 4 5 6Channels using Queues ChannelsStage 2 Event Event Event Processor 1 Processor 2 Processor 3 26
  27. 27. SEDA: another view Processor Queue 2 Source 1 Processor Queue 1 Source 2 Processor Queue 3 Stage 1 Channels using Stage 2 Channels using Stage 3 Queues Queues27
  28. 28. SEDA with Camel• SEDA – Scalability feature in Camel – Uses thread pools and internal queues – Enables parallel processing – Avoids waiting threads28
  29. 29. Camel with SEDA: comparison Waiting thread without SEDA Parallel processing with SEDA Thread 1 Receive Receive Thread 2 SEDA Queue 1 Validate Validate Thread 1 Normalize Normalize Enrich SEDA Queue 2 Split Split Enrich Thread 3 Route Route• Impact • For 100 concurrent requests – significant reduction in thread – Without SEDA: 100 threads; With SEDA: 30 threads 29 consumption
  30. 30. Camel as a part of EDA• Camel as – Event channel – Event processor Camel30
  31. 31. Camel as Event Channel• SEDA queues• VM queues• Multi-threaded flow• Load balanced flow• Asynchronous API31
  32. 32. 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, logging32
  33. 33. Camel and the Actor Model with Akka• Actor Model Actor – Actors Behavior • Similar to objects, many other features • Mailbox, behavior/s, internal state Mailbox 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 Akka33
  34. 34. Summary• Camel – Integration Framework – Simplicity and flexibility – Components• EDA with Camel – SEDA – SEDA within Camel – Camel as part of SEDA• Akka and Camel for EDA34
  35. 35. QuestionsGnanaguru Sattanathan Prajod Vettiyattil Twitter:@gnanagurus Twitter: @prajodsWebsite: bushorn.com Our Open Source Middleware Group on LinkedIn http://tinyurl.com/be6e93q35