enterprise integration patterns with apache camel
DESCRIPTION
Enterprise integration patterns, Apache Camel, EIPTRANSCRIPT
● 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 (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 (7)
Event driven consumer
Pooling consumer
Transactional client
Service activator
Messaging Endpoints
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/
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
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
● Java interface used to implement message consumers or Message Translator EIP
● you can create a Component from a Processor
Camel Processor
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
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
Error Handling
Two distinct types:● transactional● non-transactional
Can configure policies like:● message redelivery● dead-letter queue
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.
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
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○ …..
Conclusions
● Camel is awesome tehnology● easy to get started● very powerfull● the comunity is great and helpful
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
● [email protected]● [email protected]● http://github.com/ieugen/● ro.linkedin.com/in/ieugen/