enterprise integration patterns and dsl with apache camel
Post on 05-Dec-2014
1.517 Views
Preview:
DESCRIPTION
TRANSCRIPT
Copyright © 2010 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
A Progress So3ware Company
Enterprise Integra6on PaDerns and DSLwith Apache Camel
1
by Claus Ibsen
Principal So3ware Engineer, FuseSource
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company2
Agenda
Who is Claus Ibsen? What is Apache Camel? Camel Architecture Whats included in the box? Running Camel Live Demos Apache ServiceMix Apache Camel Roadmap Q and A
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company3
Who is Claus Ibsen?
Principal So3ware Engineer at FuseSource• Full 6me Apache Camel hacker
Apache Camel commiDer• Camel Top Contributor• 4 years working with Camel
Author of Camel in Ac6on book Contact
• TwiDer: @davsclaus• Blog: hDp://davsclaus.blogspot.com• Email: cibsen@fusesource.com
hDp://www.manning.com/ibsen
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company4
FuseSource -‐ hDp://fusesource.com
My Employer
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company5
Agenda
Who is Claus Ibsen? What is Apache Camel? Camel Architecture Whats included in the box? Running Camel Live Demos Apache ServiceMix Apache Camel Roadmap Q and A
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Quote from the web site • hDp://camel.apache.org
6
Apache Camel is apowerful Open SourceIntegra6on Framework
based on knownEnterprise Integra6on PaDerns
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Why do we need integra6on?• Your apps are build using different tech stacks
• Cri6cal for your business to integrate
Why Integra6on Framework?• Framework do the heavy li3ing
• Focus on business problem
• Not "reinven6ng the wheel"
7
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
What is Enterprise Integra6on PaDerns?
8
System A System B
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
What is Enterprise Integra6on PaDerns?
9
Its a book
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Camel and EIP
10
ApacheAc6veMQ
WebSphereMQ
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Camel and EIP
11
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Camel and EIP
12
fromA
send toB
filtermessage
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Camel and EIP
13
from(A) to(B)filter(predicate)
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Camel and EIP
14
from(A) .to(B).filter(isWidget)
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Camel and EIP
15
from(A).filter(isWidget).to(B);
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Camel and EIP
16
isWidget = xpath("/quote/product = ‘widget’");
from(A).filter(isWidget).to(B);
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Camel and EIP
17
Endpoint A = endpoint("ac6vemq:queue:quote");Endpoint B = endpoint("mq:quote");Predicate isWidget = xpath("/quote/product = ‘widget’");
from(A).filter(isWidget).to(B);
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Filter Route
18
public void configure() throws Exception { Endpoint A = endpoint("activemq:queue:quote"); Endpoint B = endpoint("mq:quote"); Predicate isWidget = xpath("/quote/product = ‘widget’");
from(A).filter(isWidget).to(B);}
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Filter Route -‐ Java DSL
19
import org.apache.camel.builder.RouteBuilder;
public class FilterRoute extends RouteBuilder {
public void configure() throws Exception { Endpoint A = endpoint("activemq:queue:quote"); Endpoint B = endpoint("mq:quote"); Predicate isWidget = xpath("/quote/product = ‘widget’");
from(A).filter(isWidget).to(B); }}
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Filter Route -‐ Java DSL
20
import org.apache.camel.builder.RouteBuilder;
public class FilterRoute extends RouteBuilder {
public void configure() throws Exception { from("activemq:queue:quote") .filter().xpath("/quote/product =‘widget’") .to("mq:quote"); }}
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Lets look at the most famous paDern
21
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Content Based Router
22
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Content Based Router -‐ XML DSL
23
<camelContext> <route> <from uri="activemq:NewOrders"/> <choice> <when> <xpath>/order/product = 'widget'</xpath> <to uri="activemq:Orders.Widgets"/> </when> <otherwise> <to uri="activemq:Orders.Gadgets"/> </otherwise> </choice> </route></camelContext>
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Content Based Router -‐ Java DSL
24
from("activemq:NewOrders") .choice() .when().xpath("/order/product = 'widget'") .to("activemq:Orders.Widget") .otherwise() .to("activemq:Orders.Gadget");
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Endpoints as URIs
25
from("file:inbox/orders") .choice() .when().xpath("/order/product = 'widget'") .to("activemq:Orders.Widget") .otherwise() .to("activemq:Orders.Gadget");
use file instead
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Endpoints as URIs
26
from("file:inbox/orders?delete=true") .choice() .when().xpath("/order/product = 'widget'") .to("activemq:Orders.Widget") .otherwise() .to("activemq:Orders.Gadget");
parameters
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
What is Apache Camel
Summary• Integra6on framework• Enterprise Integra6on PaDerns (EIP) • Rou6ng (using DSL)• Easy configura6on (endpoints as URIs)• No heavy specifica6on• No container dependency• Payload agnos6c• A lot of components
27
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company28
Agenda
Who is Claus Ibsen? What is Apache Camel? Camel Architecture Enterprise Integra6on PaDerns Running Camel Live Demos Apache ServiceMix Apache Camel Roadmap Q and A
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Camel Architecture
Message PaDern
29
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Camel Architecture
Message
30
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Camel Architecture
Camel Exchange
31
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Camel Architecture
Camel Architecture
32
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Camel Architecture
Camel DSL -‐ Highest Level
33
from("file:inbox/orders?delete=true") .choice() .when().xpath("/order/product = 'widget'") .to("activemq:Orders.Widget") .otherwise() .to("activemq:Orders.Gadget");
Camel DSL -‐ Lowest Level• Rou6ng Engine
• Processor API
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Camel Architecture
34
Iterator<Processor> it = ...while (it.hasNext()) { Processor processor = it.next(); processor.process(exchange);}
process(Exchange exchange) throws Exception;
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company35
Agenda
Who is Claus Ibsen? What is Apache Camel? Camel Architecture Enterprise Integra9on Pa;erns Running Camel Live Demos Apache ServiceMix Apache Camel Roadmap Q and A
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
50 Enterprise Integra6on PaDerns
36
http://camel.apache.org/eip
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
Pipes and Filters EIP
37
from("file:inbox") .pipeline() .to("bean:decrypt") .to("bean:authenticate") .to("bean:deDup");
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
Pipes and Filters EIP
38
from("file:inbox") .to("bean:decrypt") .to("bean:authenticate") .to("bean:deDup");
pipeline() is default mode in Camel and can usually be omi5ed
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
SpliDer EIP
39
from("file:inbox") .split(body().tokenize("\n") .marshal(customToXml) .to("activemq:line");
File Splitter Custom-> XML ActiveMQ
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
Recipient List EIP
40
ActiveMQREST Service
stock.APPL
stock.ORCL
stock.XXXX
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
Recipient List EIP
41
ActiveMQREST Service
curl -‐X POST -‐d "120" "hDp://localhost:9080/stock/ORCL"
stock.APPL
stock.ORCL
stock.XXXX
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
Bean as Message Translator
42
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
Bean as Message Translator
43
public class Foo {
public String someMethod(String name) { return “Hello “ + name; }}
from("activemq:Incoming”). beanRef("myBeanName", "someMethod"). to("activemq:Outgoing");
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
Bean Parameter Binding w/ Annota6ons
44
public class Foo {
public String someMethod(String name, @Header(”JMSCorrelationID”) String cid) { ... }}
from("activemq:Incoming"). beanRef("myBeanName", "someMethod"). to("activemq:Outgoing");
Annota6ons
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Enterprise Integra6on PaDerns
Bean Parameter Binding w/ Method Name (new in Camel 2.9)
45
public class Foo {
public String someMethod(String name, String cid) { ... }}
from("activemq:Incoming"). beanRef("myBeanName", "someMethod(${body}, ${header.JMSCorrelationID})"). to("activemq:Outgoing");
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company46
Agenda
Who is Claus Ibsen? What is Apache Camel? Camel Architecture Enterprise Integra6on PaDerns Running Camel Live Demos Apache ServiceMix Apache Camel Roadmap Q and A
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Running Camel
Deployment Strategy• No container dependency• Lightweight• Embedable
Deployment Op6ons•Standalone•Spring•WAR•JEE•OSGi•Cloud
47
Known ContainersFuse ESBApache ServiceMixApache Ac6veMQApache TomcatJeDyJBossIBM WebSphereOracle WebLogicGlassfishGoogle App EngineAmazon EC2... others
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Running Camel
Java Applica6on
48
CamelContext context = new DefaultCamelContext();context.addRoutes(new MyRouteBuilder());context.start();
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Running Camel
Spring Applica6on
49
<beans xmlns="http://www.springframework.org/schema/beans">
<camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="file:/orders"/> ... </route> </camelContext>
</beans>
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Running Camel
Java Client Applica6on
50
CamelContext context = new DefaultCamelContext();context.start();
ProducerTemplate template = context.newProducerTemplate();
Object data = ...String filename = "mydata.csv";String uri = "ftp:myftpserver?username=me&password=secret";
template.sendBodyAndHeader(uri, data, "CamelFileName", filename);
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company51
Agenda
Who is Claus Ibsen? What is Apache Camel? Camel Architecture Enterprise Integra6on PaDerns Running Camel Live Demos Apache ServiceMix Apache Camel Roadmap Q and A
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Live Demo 1
Groovy Script
52
groovy mycamel.groovycurl hDp://localhost:8080
HTTP Service Transform
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Live Demo 1
Groovy Script (mycamel.groovy)
53
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Live Demo 1
Groovy Script (mycamel.groovy -‐ cont.)
54
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Live Demo 2
Create new Project using Maven
55
mvn archetype:generate(camel-‐archetype-‐spring)
mvn eclipse:eclipsemvn camel:run
File Content Based Router
UK messages
Other messages
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company
Live Demo 2
Create new Project using Maven
56
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company57
Agenda
Who is Claus Ibsen? What is Apache Camel? Camel Architecture Enterprise Integra6on PaDerns Running Camel Live Demos Apache ServiceMix Apache Camel Roadmap Q and A
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company58
Apache ServiceMix
Architecture
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company59
Apache ServiceMix
Modular
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company60
Apache ServiceMix
ServiceMix and Camel Demo
SSH access to shell
ssh smx@localhost -‐p 8101
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company61
Agenda
Who is Claus Ibsen? What is Apache Camel? Camel Architecture Enterprise Integra6on PaDerns Running Camel Live Demos Apache ServiceMix Apache Camel Roadmap Q and A
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company62
Apache Camel Roadmap
Apache Camel 2.9.0 -‐ Highlights• Reduced Spring JAR dependency• Reworked Simple Expression Language• Splisng big XML files in streaming mode• Improved Bean Parameter Binding• Improved JMX• Improved JMS request/reply• Addi6onal Camel shell commands• JClouds Component
hDp://camel.apache.org/camel-‐290-‐release.html
hDp://davsclaus.blogspot.com
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company63
Apache Camel Roadmap
Apache Camel 2.10 -‐ Roadmap• Blueprint not 6ed to Apache Aries• Transac6on API not 6ed to Spring TX API• Make it easier to use Bindy• Persistent Dead LeDer Channel• CDI support• camel-‐mina2 component
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company64
Apache Camel Roadmap
Apache Camel 3.0 -‐ Roadmap• Split camel-‐core into mul6ple JARs• Support async transac6ons• Internal rou6ng engine cleanup• Dynamic add/remove interceptors to running routes• Unify JMX/REST API for management
hDp://camel.apache.org/camel-‐30-‐roadmap.html
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company65
Agenda
Who is Claus Ibsen? What is Apache Camel? Camel Architecture Enterprise Integra6on PaDerns Running Camel Live Demos Apache ServiceMix Apache Camel Roadmap Q and A
Copyright © 2011 Progress So3ware Corpora6on and/or its subsidiaries or affiliates. All rights reserved. A Progress So3ware Company66
Q and A
? Contact
• TwiDer: @davsclaus• Blog: hDp://davsclaus.blogspot.com• Email: cibsen@fusesource.com
top related