Enterprise Integration
Patterns
with
Apache Camel
Ioan Eugen Stan
20 Septembrie 2013
Axway Kickoff
● Why = The purpose - What is
you cause? What do you belive
in?
● How = The Process - specifc
actions taken to realize the Why
● What = The result - what do
you do, the result of Why. Proof.
TED, Simon Sinek, May 2010
Why do we need
integration?
A integra = include, a (se) îngloba, a (se)
încorpora, a (se) armoniza într-un tot.
Why EIP Where does complexity
come from?
Much of the complexity stems from two issues:
● dealing with the specifics of applications and
transports
● coming up with good solutions to integration
problems
The Book
● 65 design patterns
● Formalized language
● Covers:
○ Integration Styles
○ Messaging Systems
○ Message Construction
○ Message Routing
○ Message Transformation
○ Messaging Endpoints
○ System Management
EIPs in detail (1)
Message
Pipes and Filters
Message translator
Message router
Messaging Systems
EIPs in detail (2)
Point to Point channel
Publish Subscribe Channel
Dead letter queue
Guaranteed delivery
Messaging Channels
EIPs in detail (3)
Event message
Request reply
Correlation identifier
Return Address
Messaging Construction
EIPs in detail (4)
Content based router
Message filter
Dynamic router
Recipient list
Messaging Routing
EIPs in detail (5)
Splitter
Aggregator
Resequencer
Routing slip
Messaging Routing
EIPs in detail (6)
Content enricher
Content filter
Claim check
Normalizer
Messaging Transformation
EIPs in detail (7)
Event driven consumer
Pooling consumer
Transactional client
Service activator
Messaging Endpoints
EIPs in detail (8)
Control bus
Detour
Wire Tap
System Management
Flight Mash-up
Image from: http://appzdevelop.blogspot.ro/2012/02/apache-camel-flight-aggregation-mashup.html
Code: https://code.google.com/p/apache-camel-mashup/
Purchase example
Normalization
Transform multiple message types into a common format
Other examples
Apache Camel
● java framework for integration and mediation
● rules in multiple DSLs:
○ Fluent Java
○ Spring XML
○ Blueprint XML
○ Scala
● over > 150 out-of-box components
● bean binding and integration with popular
frameworks
● active comunity ~ 900 messages/month
Camel Architecture
Image from: http://java.dzone.com/articles/open-source-integration-apache (Camel in Action)
Basics
● create a CamelContext
● optionally configure components or
endpoints
● add routing rules
● start the context
Example Java DSL
Example Spring DSL
Vocabulary: Component & Endpoint
● Component is an Endpoint factory
● Enpoints are refered by URIs: file://, jms://
● Has methods:
○ createProducer()
○ createConsumer()
○ createPoolingConsumer()
(Some) Standard components
● AHC - Async HTTP client
● Atom
● AMPQ
● AWS-* - Amazon cloud services
● Bean - Bean binding
● DNS - DNS look-up
● Elasticsearch
● JPA
● File & FTP
● HBase
● HTTP
● LDAP
● MongoDB
● Mustache
● Netty
● POP3
● RabbitMQ
● Salesforce
● Servlet
● JMS & ActiveMQ
● SQL
● SSH
● Validation - XML validation
● Websocket
● XMPP
● Activiti BPMN
● Smooks
Vocabulary: Exchange
● Exchange = Wrapper object
● encapsulates Messages (IN and
OUT) and Metadata
● Java interface used to implement message consumers
or Message Translator EIP
● you can create a Component from a Processor
Camel Processor
Remember
Processing files with Apache Camel
Content Based Router EIP
Route messages to destination based on message contents
Content Based Router - Spring DSL
Normalizer EIP
Camel ETL - sample
● read files from src/data/ directory
● convert content to PersonDocument class using TypeConvertor system
(JAXB)
● persist to DB using JPA component using TypeConvertor
● read from DB with JPA component as entity class
● convert entity to XML file with JAXB and File component
Transactional Client EIP
Make client session with messaging system transactional
● uses Spring transactions
● Transactional endpoints: JMS, ActiveMQ, AMPQ, JPA
Camel also supports Transactional Routes
Transactional Client
Load Balancer Pattern
● delegate processing based on load
balancing policies
● out-of-the-box-policies:
○ Round robin
○ Random
○ Sticky
○ Topic
○ Failover
○ Weighted Round-robin
○ Weighted random
○ Custom
Load Balancer
Error Handling
Two distinct types:
● transactional
● non-transactional
Can configure policies like:
● message redelivery
● dead-letter queue
Error Handling - Try - Catch
Error Handling - Dead Letter Queue
● exceptions caught by Dead Letter Channel - which
decides either:
○ to redeliver
○ or send to dead letted queue
Camel BAM
● business activity monitoring framework
● monitor business processes across multiple exchanges
● works across different endpoints
For every purchase order created by A, B generates an invoice.
Flight Mash-up revisited
Tooling: Fuse IDE
● Eclipse based RedHat JBoss product
● build Camel routes graphically (Spring XML
DSL)
● import existing XML routes
● comes with pre-defined EIP building blocks
● view local and remote ActiveMq brokers,
Camel end-points and routes
● trace Camel routes at run-time
Fuse IDE - diagram view
Hawt.io - ultimate admin console
● lightweight html5 modular web-console
● open-source (JBoss Cumunity project)
● discovers what the JVM is running (JMX,
other) and exposes a web UI
● lots of plugins:
○ ActiveMQ - default console for 5.9.x
○ Camel - view/control routes
○ OSGi - view/control bundles
○ Karaf
○ JMX
○ …..
Hawt.io - view routes
Hawt.io - ActiveMQ - browse/send
Hawt.io - monitor
Hawt.io - inspect JMX
Conclusions
● Camel is awesome tehnology
● easy to get started
● very powerfull
● the comunity is great and helpful
Întrebări?
Resources
● http://camel.apache.org
● https://access.redhat.com/site/documentation/Fuse_ESB_Enterprise/
● http://www.eaipatterns.com/
● http://java.dzone.com/articles/open-source-integration-apache
● http://activemq.apache.org/
● http://hawt.io/
● http://fusesource.com/products/fuse-ide/
● https://code.google.com/p/apache-camel-mashup/
● http://appzdevelop.blogspot.ro/2012/02/apache-camel-flight-aggregation-
mashup.html
Contact
● stan.ieugen@gmail.com
● ieugen@apache.org
● http://github.com/ieugen/
● ro.linkedin.com/in/ieugen/

Enterprise Integration Patterns with Apache Camel

  • 1.
    Enterprise Integration Patterns with Apache Camel IoanEugen Stan 20 Septembrie 2013 Axway Kickoff
  • 2.
    ● Why =The purpose - What is you cause? What do you belive in? ● How = The Process - specifc actions taken to realize the Why ● What = The result - what do you do, the result of Why. Proof. TED, Simon Sinek, May 2010
  • 3.
    Why do weneed integration? A integra = include, a (se) îngloba, a (se) încorpora, a (se) armoniza într-un tot.
  • 5.
    Why EIP Wheredoes complexity come from? Much of the complexity stems from two issues: ● dealing with the specifics of applications and transports ● coming up with good solutions to integration problems
  • 6.
    The Book ● 65design patterns ● Formalized language ● Covers: ○ Integration Styles ○ Messaging Systems ○ Message Construction ○ Message Routing ○ Message Transformation ○ Messaging Endpoints ○ System Management
  • 7.
    EIPs in detail(1) Message Pipes and Filters Message translator Message router Messaging Systems
  • 8.
    EIPs in detail(2) Point to Point channel Publish Subscribe Channel Dead letter queue Guaranteed delivery Messaging Channels
  • 9.
    EIPs in detail(3) Event message Request reply Correlation identifier Return Address Messaging Construction
  • 10.
    EIPs in detail(4) Content based router Message filter Dynamic router Recipient list Messaging Routing
  • 11.
    EIPs in detail(5) Splitter Aggregator Resequencer Routing slip Messaging Routing
  • 12.
    EIPs in detail(6) Content enricher Content filter Claim check Normalizer Messaging Transformation
  • 13.
    EIPs in detail(7) Event driven consumer Pooling consumer Transactional client Service activator Messaging Endpoints
  • 14.
    EIPs in detail(8) Control bus Detour Wire Tap System Management
  • 15.
    Flight Mash-up Image from:http://appzdevelop.blogspot.ro/2012/02/apache-camel-flight-aggregation-mashup.html Code: https://code.google.com/p/apache-camel-mashup/
  • 16.
  • 17.
    Normalization Transform multiple messagetypes into a common format
  • 18.
  • 19.
    Apache Camel ● javaframework for integration and mediation ● rules in multiple DSLs: ○ Fluent Java ○ Spring XML ○ Blueprint XML ○ Scala ● over > 150 out-of-box components ● bean binding and integration with popular frameworks ● active comunity ~ 900 messages/month
  • 20.
    Camel Architecture Image from:http://java.dzone.com/articles/open-source-integration-apache (Camel in Action)
  • 21.
    Basics ● create aCamelContext ● optionally configure components or endpoints ● add routing rules ● start the context
  • 22.
  • 23.
  • 24.
    Vocabulary: Component &Endpoint ● Component is an Endpoint factory ● Enpoints are refered by URIs: file://, jms:// ● Has methods: ○ createProducer() ○ createConsumer() ○ createPoolingConsumer()
  • 25.
    (Some) Standard components ●AHC - Async HTTP client ● Atom ● AMPQ ● AWS-* - Amazon cloud services ● Bean - Bean binding ● DNS - DNS look-up ● Elasticsearch ● JPA ● File & FTP ● HBase ● HTTP ● LDAP ● MongoDB ● Mustache ● Netty ● POP3 ● RabbitMQ ● Salesforce ● Servlet ● JMS & ActiveMQ ● SQL ● SSH ● Validation - XML validation ● Websocket ● XMPP ● Activiti BPMN ● Smooks
  • 26.
    Vocabulary: Exchange ● Exchange= Wrapper object ● encapsulates Messages (IN and OUT) and Metadata
  • 27.
    ● Java interfaceused to implement message consumers or Message Translator EIP ● you can create a Component from a Processor Camel Processor
  • 28.
  • 29.
    Content Based RouterEIP Route messages to destination based on message contents
  • 30.
  • 31.
  • 32.
    Camel ETL -sample ● read files from src/data/ directory ● convert content to PersonDocument class using TypeConvertor system (JAXB) ● persist to DB using JPA component using TypeConvertor ● read from DB with JPA component as entity class ● convert entity to XML file with JAXB and File component
  • 33.
    Transactional Client EIP Makeclient session with messaging system transactional ● uses Spring transactions ● Transactional endpoints: JMS, ActiveMQ, AMPQ, JPA Camel also supports Transactional Routes
  • 34.
  • 35.
    Load Balancer Pattern ●delegate processing based on load balancing policies ● out-of-the-box-policies: ○ Round robin ○ Random ○ Sticky ○ Topic ○ Failover ○ Weighted Round-robin ○ Weighted random ○ Custom
  • 36.
  • 37.
    Error Handling Two distincttypes: ● transactional ● non-transactional Can configure policies like: ● message redelivery ● dead-letter queue
  • 38.
    Error Handling -Try - Catch
  • 39.
    Error Handling -Dead Letter Queue ● exceptions caught by Dead Letter Channel - which decides either: ○ to redeliver ○ or send to dead letted queue
  • 40.
    Camel BAM ● businessactivity monitoring framework ● monitor business processes across multiple exchanges ● works across different endpoints For every purchase order created by A, B generates an invoice.
  • 41.
  • 42.
    Tooling: Fuse IDE ●Eclipse based RedHat JBoss product ● build Camel routes graphically (Spring XML DSL) ● import existing XML routes ● comes with pre-defined EIP building blocks ● view local and remote ActiveMq brokers, Camel end-points and routes ● trace Camel routes at run-time
  • 43.
    Fuse IDE -diagram view
  • 44.
    Hawt.io - ultimateadmin console ● lightweight html5 modular web-console ● open-source (JBoss Cumunity project) ● discovers what the JVM is running (JMX, other) and exposes a web UI ● lots of plugins: ○ ActiveMQ - default console for 5.9.x ○ Camel - view/control routes ○ OSGi - view/control bundles ○ Karaf ○ JMX ○ …..
  • 45.
  • 46.
    Hawt.io - ActiveMQ- browse/send
  • 47.
  • 48.
  • 49.
    Conclusions ● Camel isawesome tehnology ● easy to get started ● very powerfull ● the comunity is great and helpful
  • 50.
  • 51.
    Resources ● http://camel.apache.org ● https://access.redhat.com/site/documentation/Fuse_ESB_Enterprise/ ●http://www.eaipatterns.com/ ● http://java.dzone.com/articles/open-source-integration-apache ● http://activemq.apache.org/ ● http://hawt.io/ ● http://fusesource.com/products/fuse-ide/ ● https://code.google.com/p/apache-camel-mashup/ ● http://appzdevelop.blogspot.ro/2012/02/apache-camel-flight-aggregation- mashup.html
  • 52.
    Contact ● stan.ieugen@gmail.com ● ieugen@apache.org ●http://github.com/ieugen/ ● ro.linkedin.com/in/ieugen/