Más contenido relacionado

Event Driven Architecture with Apache Camel

  1. 1
  2. Event Driven Architectures with Camel Gnanaguru Sattanathan Twitter:@gnanagurus Website: bushorn.com Prajod Vettiyattil Twitter: @prajods 2
  3. What this session is about Application Integration Apache Camel Event Driven Architectures with Camel 3
  4. Application Integration 4
  5. 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
  6. The Chameleon 6
  7. Camel is a reptile ! 7
  8. The Chameleon It can change color with the container  Camel JVM Camel Tomcat Camel JBoss Camel Websphere Camel Oracle Fusion Camel Jetty 8
  9. Apache Camel •Integration framework •Multiple deployment options •Feature rich •Simple to program •Unique scalability features •Apache License 9
  10. Apache Camel: Components •More than 100 readymade components •Covering –PaaS & Public Clouds –Social Networks –Devices –Almost all standard protocols 10
  11. 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
  12. Coding with Camel 12
  13. Camel – Code your way JAVA SPRING GROOVY SCALA Domain Specific Language (DSL) 13
  14. A simple file integration File System Input Directory Output Directory File 14
  15. Simple file integration: Sample Code <route> <from uri="file://d:Input"/> <to uri="file://d:Output"/> </route> 15 using Spring XML
  16. Message Broker ( ActiveMQ) File System – Message Broker Integration File System Input Directory Output Queue File 16
  17. File System to Message Broker Integration: Sample Code <route> <from uri="file://d:Input"/> <to uri="activemq:queue:Output"/> </route> 17 using Spring XML
  18. Transformer Message Broker ( ActiveMQ) Adding a simple transformation File System Input Directory Output Queue File 18
  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> 19 using Spring XML
  20. A simple Twitter application Message Broker ( ActiveMQ) Twitter.com Tweets Tweets Queue 20 Tweets
  21. A simple Twitter application: Sample Code <route> <from uri="twitter://search ?type=direct &keywords=JUDCON”/> <to uri="activemq:queue:Output"/> </route> 21
  22. Event Driven Architectures with Camel 22
  23. Event Driven Architecture •EDA •A software architecture pattern •Event: Significant change in state •Parts of the architecture –Event source –Event channel –Event processor 23
  24. EDA Source 1 Event Processor 1 Source 2 Event Processor 2 Source 3 Event Processor 3 Source 4 Source 5 Source 6 Sources Channels Processors 24
  25. 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
  26. 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 Stage 1 Channels using Queues Stage 2 26
  27. 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
  28. SEDA with Camel •SEDA –Scalability feature in Camel –Uses thread pools and internal queues –Enables parallel processing –Avoids waiting threads 28
  29. Camel with SEDA: comparison Normalize Enrich Split Route Waiting thread without SEDA Thread 1 Receive Receive Validate Normalize Enrich Route Parallel processing with SEDA Thread 1 Thread 2 Thread 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
  30. Camel as a part of EDA •Camel as –Event channel –Event processor 30 Camel
  31. Camel as Event Channel •SEDA queues •VM queues •Multi-threaded flow •Load balanced flow •Asynchronous API 31
  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, logging 32
  33. 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
  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 EDA 34
  35. Questions 35 Gnanaguru Sattanathan Twitter:@gnanagurus Website: bushorn.com Prajod Vettiyattil Twitter: @prajods Our Open Source Middleware Group on LinkedIn http://tinyurl.com/be6e93q