solving enterprise integration with apache camel
DESCRIPTION
Talk given at Phoenix Desert Code Camp on enterprise integration, enterprise service bus, and Apache CamelTRANSCRIPT
![Page 1: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/1.jpg)
1 1
Solving Enterprise Integration With
Apache Camel
Christian Posta Principal Consultant and Architect 11/09/13
![Page 2: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/2.jpg)
2
• What is Integration?
• What is Apache Camel
• Why Apache Camel?
• Example
• Questions?
Agenda
![Page 3: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/3.jpg)
3
Your speaker Christian Posta Blog: http://christianposta.com/blog
Twitter: @christianposta
Email: [email protected]
• Principal Consultant and Architect at Red Hat (FuseSource)
• Based in Phoenix, AZ
• Committer on Apache Camel, ActiveMQ, Apollo
• PMC on ActiveMQ
• Author: Essential Camel Components DZone Refcard
![Page 4: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/4.jpg)
4 4
What is Integration?
![Page 5: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/5.jpg)
5
Integration?
![Page 6: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/6.jpg)
6
Integration…
![Page 7: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/7.jpg)
7
Just use one computer.
No integration needed.
![Page 8: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/8.jpg)
8
• Off the shelf? Home Grown? Acquisition? • Platforms • Protocols / Data Formats • Data Formats • Timing • Organizational mismatch
Why is integration hard?
![Page 9: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/9.jpg)
9
Commercial Solutions?
![Page 10: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/10.jpg)
10
Enterprise Service Bus?
![Page 11: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/11.jpg)
11
Enterprise Service Bus…
![Page 12: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/12.jpg)
12
• Protocol mediation • Routing • Transformation • EIPs • Start small, build up • Open Source • Community driven
Extract the heart of ESB
![Page 13: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/13.jpg)
13
• Common language!!!!! • Specific context • Forces at work • Concrete solution • Guidance • Other patterns… • 65 patterns
Patterns FTW!
![Page 14: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/14.jpg)
14 14
What is Apache Camel?
![Page 15: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/15.jpg)
15
Proud parents of Camel
![Page 16: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/16.jpg)
16
Apache Camel Apache Camel is an open-source,
light-weight, integration library.
Use Camel to integrate disparate systems that speak different protocols and data formats
![Page 17: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/17.jpg)
17
• Can carry more weight that other beasts?
• James fancied the cigarettes? • A horse designed by committee?
Why the name Camel?
Concise Application Messaging Exchange Language
![Page 18: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/18.jpg)
18
• Light-weight integration library • Enterprise Integration Patterns • Components • Domain Specific Language • Routing and Mediation (like an ESB?) • Runs in any container (or stand alone)
What is Apache Camel?
![Page 19: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/19.jpg)
19
• An integration library • Routing (content-based, dynamic, rules-engine…) • Mediation (xformations, protocols, wire transports…) • DSL
• Can build an ESB (real ESB.. Not just box in the middle)
• Many options based on Camel! • Fuse ESB / JBoss Fuse • Apache ServiceMix (Karaf + Camel) • Talend, wso2, others… • Not tied to vendor lock-in and commercial licenses!
Not an ESB…per-se…
![Page 20: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/20.jpg)
20 20
Quick Example
![Page 21: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/21.jpg)
21
Quick Example
File System Message Oriented Middleware
![Page 22: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/22.jpg)
22
Quick Example
From A Send to B Filter message
![Page 23: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/23.jpg)
23
Quick Example
from(A) to(B) filter(predicate)
![Page 24: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/24.jpg)
24
Quick Example
from(A) .to(B) .filter(isWidget)
![Page 25: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/25.jpg)
25
Quick Example
isWidget = xpath(“/quote/product = ‘widget’”); from(A) .filter(isWidget). to(B)
![Page 26: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/26.jpg)
26 26
Using Camel
![Page 27: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/27.jpg)
27
Very popular
• Used at top companies in finance, shipping,
retail/e-retail, health care, airline
reservations, etc
• FAA: http://fusesource.com/collateral/131
• Sabre: http://fusesource.com/collateral/139
• CERN: http://fusesource.com/collateral/103
![Page 28: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/28.jpg)
28
Open source
• Apache Software Foundation
• ASL v 2.0 Licensed
• Vibrant community • Jira, mailing list, github
• Lots of contributions! Check out the components!
![Page 29: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/29.jpg)
29
Pipes and Filters
• Step by Step – “Processors” in Camel terminology • Complex processing – “Routes” • Flexible • Testing • Reuse
![Page 30: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/30.jpg)
30
• Defined in Java, XML, Scala, Groovy • Step by step processing of a message:
• Consumer – Listen for incoming message • Zero or more “filters” or Processors • Producer – Send outgoing message
• Number of processing filters, or “Processors” in Camel-speak • EIPs • Tranform, redirect, enrich
Camel Routes
![Page 31: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/31.jpg)
31
Domain Specific Language • Domain specific (integration) • Used to build and describe Camel Routes • Embedded within a general programming language • Java, Spring XML, Scala, Groovy • Take advantage of existing tools • Fluent builders (builder pattern…)
• from(“..”).enrich(“…”).filter(“..”).to(“…”);
![Page 32: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/32.jpg)
32
Java DSL
public class OrderProcessorRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from(“activemq:orders”)
.choice() .when(header(“customer-rating”).isEqualTo(“gold”)) .to(“ibmmq:topic:specialCustomer”) .otherwise() .to(“ftp://user@host/orders/regularCustomers”) .end() .log(“received new order ${body.orderId}”) .to(“ibatis:storeOrder?statementType=Insert”); }}
![Page 33: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/33.jpg)
33
Spring XML DSL
<route id=“processOrders”> <from uri=“activemq:orders”/>
<choice> <when> <simple>${header.customer-rating} == ‘gold’</simple> <to uri=“ibmmq:topic:specialCustomer”> </when>
<otherwise> <to uri=“ftp://user@host/orders/regularCustomers” /> </otherwise>
</choice> <log message=“received new order ${body.orderId}”/> <to uri=“ibatis:storeOrder?statementType=Insert”/> </route>
![Page 34: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/34.jpg)
34
• Message Routing • Transformation • Aggregation • Splitting • Resequencer • Routing Slip • Enricher • All from the book!
Enterprise Integration Patterns
![Page 35: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/35.jpg)
35
• Prepackaged bits of code • Highly configurable • Maximum interoperability • Used to build “Adapters” to existing systems • Don’t reinvent the wheel and end up with a box
Components
![Page 36: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/36.jpg)
36
Components • ActiveMQ, Websphere, Weblogic (JMS)
• AMQP
• ATOM feeds
• AWS (S3, SQS, SNS, others)
• Bean
• Cache (EHCache)
• CXF (JAX-WS, JAX-RS)
• EJB
• Drools
• File
• FTP
• Google App Engine
• GMail
• HTTP
• IRC
• jclouds
• JDBC
• Jetty
• MQTT
• MyBatis
• JPA
• Spring Integration
• Spring Web Services
http://camel.apache.org/components.html
To see list of all components!!
![Page 37: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/37.jpg)
37
• URI format: • scheme:localPart[?options]
• scheme: identifies the “component” • localPart: specific to the component • options: is a list of name-value pairs
• Creates endpoints based on configuration • Route endpoint “factories” • Integrate with Camel Routes by creating producer/
consumer endpoints
Components
![Page 38: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/38.jpg)
38
Another Example
public class MyExampleRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from(“aws-sqs://demo?defaultVisibilityTimeout=2”) .setHeader(“type”).jsonpath(“$[‘type’]”)
.filter(simple(“${header.type} == ‘login’”) .to(“jms:quote”);
}}
![Page 39: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/39.jpg)
39
Test Framework • Powerful way to test your Camel routes
• http://camel.apache.org/mock.html
• Uses Mocks • Mocks vs Stubs? • http://martinfowler.com/articles/mocksArentStubs.html
• Provides declarative testing mechanism • Declare • Test • Assert
![Page 40: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/40.jpg)
40
Management with HawtIO http://hawt.io
![Page 41: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/41.jpg)
41
Developer Tooling Support Fuse IDE
![Page 42: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/42.jpg)
42
JBoss Fuse (aka Fuse ESB)
![Page 43: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/43.jpg)
43
JBoss Fuse (aka Fuse ESB)
![Page 44: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/44.jpg)
44 44
Live Demo
can be found here: https://github.com/christian-posta/camel-sqs-example
![Page 45: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/45.jpg)
45 45
Resources
![Page 46: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/46.jpg)
46
Dzone Refcardz
• Camel Essential Components • http://refcardz.dzone.com/refcardz/essential-camel-components
• Essential EIP with Apache Camel • http://refcardz.dzone.com/refcardz/enterprise-integration
REFCARDZ
![Page 47: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/47.jpg)
47
Apache Community • http://camel.apache.org • Mailing list: [email protected] • Nabble Archive:
http://camel.465427.n5.nabble.com/Camel-Users-f465428.html
• Source code: http://svn.apache.org/viewvc/camel/trunk/
• Blogs, Articles, Examples • http://camel.apache.org/articles.html • http://camel.apache.org/user-stories.html
• http://camel.apache.org/user-stories.html • http://www.davsclaus.com • http://www.christianposta.com/blog
![Page 48: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/48.jpg)
48
Apache Camel Books
![Page 49: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/49.jpg)
49
Apache Camel Books
![Page 50: Solving Enterprise Integration with Apache Camel](https://reader030.vdocuments.site/reader030/viewer/2022013107/548c4ef1b479590d2b8b47b2/html5/thumbnails/50.jpg)
50 50
Questions