apache camel - fuse community day london 2010 presentation
DESCRIPTION
My Apache Camel presentation from the FUSE community day event, London June 2010. A video/audio/transcript of the presentation is in the works and will later be published at the fusesource (http://fusesource.com) website.TRANSCRIPT
1
Apache Camel
Claus IbsenPrincipal Software Engineer, Progress SoftwareJune 2010
Tuesday, June 8, 2010
© 2009 Progress Software Corporation2
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation3
Who is Claus Ibsen?
Principal Software Engineer at Progress Software• Full time Apache Camel hacker
Apache Camel committer for 2+ years• 30 months working with Camel
Co-author of Camel in Action book• Available in Q3 2010
Contact• [email protected]• [email protected]• http://davsclaus.blogspot.com/• http://twitter.com/davsclaus
Tuesday, June 8, 2010
© 2009 Progress Software Corporation4
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation5
The birth of Apache Camel
• Camel’s parents
Tuesday, June 8, 2010
© 2009 Progress Software Corporation6
The birth of Apache Camel
Initial Commit Logr519901 | jstrachan | 2007-03-19 11:54:57 +0100(Mon, 19 Mar 2007) | 1 line
Initial checkin of Camel routing library
Apache Camel 1.0 released June 2007
Apache Camel is 3 years old
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
The birth of Apache Camel
7
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
The birth of Apache Camel
My initial commit
r640963 | davsclaus | 2008-03-25 21:07:10 +0100(Tue, 25 Mar 2008) | 1 line
Added unit test for mistyped URI
8
Tuesday, June 8, 2010
© 2009 Progress Software Corporation9
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Quote from the web site
10
Apache Camel is aPowerful Open SourceIntegration Framework
based on knownEnterprise Integration Patterns
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
What are Enterprise Integration Patterns?
11
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
What are Enterprise Integration Patterns?
12
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
What are Enterprise Integration Patterns?
13
Its a book
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Lets look at one of the patterns
14
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Use Case
15
ActiveMQ WebSphereMQ
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Pattern
16
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Pattern
17
fromA
send toB
filtermessage
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Pattern
18
from(A) to(B)filter(predicate)
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Pattern
19
from(A) .to(B).filter(isWidget)
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Route
20
from(A).filter(isWidget).to(B);
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Route
21
isWidget = xpath(“/quote/product = ‘widget’”);
from(A).filter(isWidget).to(B);
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Route
22
Endpoint A = endpoint(“activemq:queue:quote”);
Endpoint B = endpoint(“mq:quote”);
Predicate isWidget = xpath(“/quote/product = ‘widget’”);
from(A).filter(isWidget).to(B);
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Route - Java DSL
23
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);}
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Route - Java DSL
24
import org.apache.camel.builder.RouteBuilder;import static org.apache.camel.builder.xml.XPathBuilder.xpath;
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); }}
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Filter Route - Java DSL
25
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"); }}
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
IDE Tooling
26
Code Assistance
JavaDoc
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
IDE Tooling
27
Code Assistance
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Recap - Concepts of Camel• Enterprise Integration Patterns• Routing• Domain Specific Language (DSL)• Endpoints• URIs• Predicates & Expressions• Components
and much more ...
28
Simplify Integration
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Lets look at the most famous pattern
29
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Content Based Router
30
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Content Based Router - Spring XML
31
<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>
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
What is Apache Camel
Content Based Router - Java DSL
32
from("activemq:NewOrders") .choice() .when().xpath(“/order/product = 'widget'”) .to(“activemq:Orders.Widget”); .otherwise() .to(“acitvemq:Orders.Gadget”);
Tuesday, June 8, 2010
© 2009 Progress Software Corporation33
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation34
A little example
Based on community user (Gunnar Hillert)• http://hillert.blogspot.com/2009/09/camellos-discovering-apache-
camel-ii.html Goals
• 1) Pickup files from a directory• 2) Make sure we only pickup 3 files per 30 seconds• 3) Store into JMS queue• 4) Listen on JMS queue• 5) And upload file to FTP server
Tuesday, June 8, 2010
© 2009 Progress Software Corporation35
A little example
Goals using Enterprise Integration Patterns
Goals• 1) Pickup files from a directory• 2) Make sure we only pickup 3 files per 30 seconds• 3) Store into JMS queue• 4) Listen on JMS queue• 5) And upload file to FTP server
1 2 3 4 5
Tuesday, June 8, 2010
© 2009 Progress Software Corporation36
A little example
Goals using Enterprise Integration Patterns
Goals• 1) Pickup files from a directory• 2) Make sure we only pickup 3 files per 30 seconds• 3) Store into JMS queue• 4) Listen on JMS queue• 5) And upload file to FTP server
from throttle to from to
Tuesday, June 8, 2010
© 2009 Progress Software Corporation37
A little example
Camel DSL in XML
<camelContext> <route> <from uri="file:camellos/inbox?move=.done"/> <throttle maximumRequestsPerPeriod="3” timePeriodMillis="30000”> <to uri="activemq:queue:camellos"/> </throttle> </route> <route> <from uri="activemq:queue:camellos"/> <to uri="ftp://admin:secret@localhost:3333"/> </route></camelContext>
Tuesday, June 8, 2010
© 2009 Progress Software Corporation38
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Highlights of whats included in Camel
39
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
70+ Components
40
activemq crypto flatpack irc ldap
activemq-journal cxf freemarker javaspace mail/imap/pop3
amqp cxfrs ftp/ftps/sftp jbi mina
atom dataset gae jcr mock
bean direct hdfs jdbc msv
bean validation esper hibernate jetty nagios
browse event hl7 jms netty
cache exec http jpa nmr
cometd file ibatis jt/400 printer
http://camel.apache.org/components.html
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
70+ Components
41
properties scalate stream xslt
quartz seda string-template ejb
quickfix servlet test
ref smooks timer
restlet smpp validation
rmi snmp velocity
rnc spring-integration vm
rng spring-security xmpp
rss sql xquery
http://camel.apache.org/components.html
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
18 Data Formats
42
bindy protobuf
castor serialization
csv soap
crypto tidy markup
flatpack xml beans
gzip xml security
hl7 xstream
jaxb zip
json dozer
http://camel.apache.org/data-format.html
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Data Format
43
from("activemq:QueueWithJavaObjects”) .marshal().jaxb() .to("mq:QueueWithXmlMessages");
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Predicates & Expressions
44
BeanShell PHP
EL Python
Groovy Ruby
JavaScript Simple
JSR 223 SQL
OGNL XPath
MVEL XQuery
http://camel.apache.org/languages.html
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
DSL in 3 programming languages
45
from(A).filter(isWidget).to(B);
from(A) filter(isWidget) --> B
<route> <from ref="A"/> <filter> <xpath>/quote/product = ‘widget’</xpath> <to ref="B"/> </filter></route>
XMLJava
Scala
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Type Converters
46
INFO DefaultTypeConverter- Loaded 148 type converters
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Custom Type Converters
47
# META-INF/services/org/apache/camel/TypeConvertercom.acme.converters
META-INF file in the JAR
@Converterpublic class MyTypeConverter { @Converter public String toString(MyOrder order) { StringBuilder sb = new StringBuilder(); ... return sb.toString(); }}
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Powerful bean integration• Adapt to your beans• EIP as @annotations
- @Produce- @Consume- @RecipientList- @RoutingSlip
48
more to come in future releases ...
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Bean as Message Translator
49
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Bean as Message Translator
50
public class Foo {
public String someMethod(String name) { return “Hello “ + name; }}
from("activemq:Incoming”). beanRef("myBeanName”, “someMethod"). to("activemq:Outgoing");
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Bean Parameter Binding with XPath
51
public class Foo {
public String processOrder( String orderAsXml, @XPath(”/order/@id”) String oid, @Header(”JMSCorrelationID”) String cid) { ... }}
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Bean Parameter Binding with Languages
52
public class Foo {
public void processOrder( MyOrder order, @Simple(”${body.customer.gold}”) boolean gold) { ... }}
MyOrder- id- customer
Customer- gold- street- zip
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Sending message
53
public class Foo { @Produce(uri="activemq:foo.bar") ProducerTemplate producer;
public void doSomething() { if (whatever) { producer.sendBody("<hello>world!</hello>"); } }}
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Sending message w/ interface
54
public interface EchoService { String sayEcho(String echo);}
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Sending message w/ interface
55
public class Echo { @Produce(uri="http://somewhere/echo") EchoService echo;
public void doTheEcho() { String reply = echo.sayEcho("Hi"); }}
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Sending message w/ no Camel API
56
public class Echo { @Autowired EchoService echo;
public void doTheEcho() { String reply = echo.sayEcho("Hi"); }}
<proxy id="echo" serviceInterface="com...EchoService" serviceUrl="http://somewhere/echo"/>
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
The EJB MessageDrivenBean in Camel
57
public class Foo {
@Consume(uri="activemq:cheese") public void onCheese(String name) { ... }}
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Test Kit• JUnit based (3.x and 4.x)• Supports Spring• Easy to test• Quick prototyping
58
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Test Kit from IDE
59
Right Click -> Run Debug
extend CamelTestSupport
Inline RouteBuilder
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Managed• JMX API• REST API
60
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Web console• REST API
61
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Whats included in the box?
Maven tooling• Maven Archetypes to create new projects
• Maven goals to run project- mvn camel:run- mvn jetty:run
62
mvn archetype:generate \ -DarchetypeGroupId=org.apache.camel.archetypes \ -DarchetypeArtifactId=camel-archetype-war \ -DarchetypeVersion=2.3.0
Tuesday, June 8, 2010
© 2009 Progress Software Corporation63
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Running Camel
Riding the Camel
64
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Running Camel
Java Application
Spring Application
65
CamelContext context = new DefaultCamelContext();context.addRoutes(new MyRouteBuilder());context.start();
<camelContext> <package>com.acme.quotes</package></camelContext>
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Running Camel
Lightweight Embeddable Known Deployment Options
• Standalone Java Application• Web Application• J2EE Application• JBI• OSGi• Google App Engine• Java Web Start• Spring Application
66
Known ContainersApache ServiceMixApache ActiveMQApache TomcatJettyJBossIBM WebSphereBEA WebLogicOracle OC4jGAE... others
Tuesday, June 8, 2010
© 2009 Progress Software Corporation67
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation68
The Camel Community
Camel website• 40% increase (comparing last two 6 month periods)• 2000-2500 visits per weekday
High activity on mailing list
http://old.nabble.com/
Tuesday, June 8, 2010
© 2009 Progress Software Corporation69
The Camel Community
High activity on mailing list (cont.)
http://markmail.org/
Tuesday, June 8, 2010
© 2009 Progress Software Corporation70
The Camel Community
20 committers
High commit activity
http://markmail.org/
Tuesday, June 8, 2010
© 2009 Progress Software Corporation71
The Camel Community
JIRA tickets
Total 2795
Open 154 (6%)
Resolved 2641 (94%)
Bugs 11 (7% open)
Oldest Bug June/29/09
June 8th 2010
Tuesday, June 8, 2010
© 2009 Progress Software Corporation72
The Camel Community
A lot in each new release
Release Date Tickets
Camel 2.0 Aug 2009 760
Camel 2.1 Dec 2009 303
Camel 2.2 Feb 2010 180
Camel 2.3 May 2010 273
Tuesday, June 8, 2010
© 2009 Progress Software Corporation73
The Camel Community
Contributors• 6 new contributed components in Camel 2.3
Contributor --> Committer
meritocracy
Tuesday, June 8, 2010
© 2009 Progress Software Corporation74
The Camel Community
3rd party integrating Camel• Apache ServiceMix• Apache ActiveMQ• Apache James• OpenESB• Progress Actional Diagnostics• FuseHQ• Open eHealth Integration Platform• Grails Camel Plugin• Play Framework• Akka• Scalate
In Progress• Drools• Smooks• Doozer• JBossESB
Tuesday, June 8, 2010
© 2009 Progress Software Corporation75
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation76
Where are we today?
Some highlights of Apache Camel 2.3• Overhauled Aggregator EIP• Easier thread pool configuration• Properties component• <routeContext> in Spring XML• 10+ new components
Tuesday, June 8, 2010
© 2009 Progress Software Corporation77
Where are we today?
Overhauled Aggregator EIP• 5 independent completion conditions
- size- timeout- interval- predicate- batch consumer
• Parallel publishing• Persistent• Transactional http://hawtdb.fusesource.org/
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Where are we today?
Overhauled Aggregator EIP
78
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Where are we today?
Overhauled Aggregator EIP
79
X
Tuesday, June 8, 2010
© 2009 Progress Software Corporation
Where are we today?
Overhauled Aggregator EIP
80
Tuesday, June 8, 2010
© 2009 Progress Software Corporation81
Where are we today?
Easier thread pool configuration
EIPsBackground
Tasks
Components
Thread Pools
Tuesday, June 8, 2010
© 2009 Progress Software Corporation82
Where are we today?
Easier thread pool configuration
EIPs Background Tasks
Components
Thread Pools
ExecutorServiceStrategy
Tuesday, June 8, 2010
© 2009 Progress Software Corporation83
Easier thread pool configuration ExecutorServiceStrategy
• API for creating and lookup thread pools• Consistent thread names• Register pools with JMX• Handle lifecycle (shutdown)
Where are we today?
Easier for Component writers
Tuesday, June 8, 2010
© 2009 Progress Software Corporation84
Where are we today?
Easier thread pool configuration ThreadPoolProfile
• Template defining pool settings• 1 default profile• 0..n custom profiles
<threadPoolProfile id="fooProfile" poolSize="20" maxPoolSize="50" maxQueueSize="200"/>
Easier for end users
Tuesday, June 8, 2010
© 2009 Progress Software Corporation85
Where are we today?
Properties Component PropertiesComponent File
{{key}}
<from uri=“jms:queue:{{inbox}}”/><to uri=“bean:validateOrder”/>
Tuesday, June 8, 2010
© 2009 Progress Software Corporation86
Where are we today?
<routeContext> in Spring XML• Re-usable route templates (in separate Spring XML files)
<routeContext id="myCoolRoutes"> <route id="cool"> <from uri="direct:start"/> <to uri="mock:result"/> </route></routeContext>
<import resource="myCoolRoutes.xml"/><camelContext> <routeContextRef ref="myCoolRoutes"/></camelContext>
myCoolRoutes.xml
Tuesday, June 8, 2010
© 2009 Progress Software Corporation87
Where are we today?
10+ new components• Properties• Nagios• Netty• Exec• JSR-303 bean validator• Spring Security• Java Cryptographic Extension• OAuth and Google Login to GAE• Eclipse RCP• SOAP (JAXB and JAX-WS)
Tuesday, June 8, 2010
© 2009 Progress Software Corporation88
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation89
Where are we going tomorrow?
Roadmap for Apache Camel 2.4 The major targets
• Asynchronous routing engine• OSGi improvements (blueprint etc.)• Security in DSL• Apache ODE component (BPEL) ?
Schedule• GA in Q3 2010
Tuesday, June 8, 2010
© 2009 Progress Software Corporation90
Agenda
Who is Claus Ibsen? The birth of Apache Camel What is Apache Camel A little example Whats included in the box? Running Camel The Camel Community Where are we today? Where are we going tomorrow? Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation91
Where do I get more information?-Camel website: http://camel.apache.org-FUSE website: http://fusesource.com-Camel in Action book: http://manning.com/ibsen
Q and A
Tuesday, June 8, 2010
© 2009 Progress Software Corporation92
Q and A
?Tuesday, June 8, 2010
© 2009 Progress Software Corporation93
Tuesday, June 8, 2010