Intro Camel

download Intro Camel

of 85

Transcript of Intro Camel

  • 8/10/2019 Intro Camel

    1/85

    1

    1

    Introduction to Apache Camel

    Claus IbsenPrincipal Software Engineer, FuseSource

    September 2010

  • 8/10/2019 Intro Camel

    2/85

    When you joined todays session

    Audio is broadcast from your computer

    Submit your questions

    via the Chat Window

    Contact todays Host

    via the Chat Window

  • 8/10/2019 Intro Camel

    3/85

    3

    2010 Progress Software Corporation3

    Today's speaker - Claus Ibsen

    Principal Software Engineer at FuseSource Full time Apache Camel hacker

    Apache Camel committer

    Co-author of Camel in Action book

    Available in late 2010

    Contact

    [email protected]

    http://davsclaus.blogspot.com/

    http://twitter.com/davsclaus

    http://www.manning.com/ibsen

    mailto:[email protected]://davsclaus.blogspot.com/http://twitter.com/davsclaushttp://www.manning.com/ibsen/http://www.manning.com/ibsen/http://twitter.com/davsclaushttp://davsclaus.blogspot.com/mailto:[email protected]
  • 8/10/2019 Intro Camel

    4/854 2010 Progress Software Corporation4

    Why the name Camel?

    Camel is easy to remember and type

  • 8/10/2019 Intro Camel

    5/855 2010 Progress Software Corporation5

    Agenda

    The birth of Apache Camel What is Apache Camel

    A little example

    What's included in the box?

    Running Camel

    Another Example

    The Camel Community

    Q and A

  • 8/10/2019 Intro Camel

    6/856 2010 Progress Software Corporation6

    The birth of Apache Camel

    Camels parents

  • 8/10/2019 Intro Camel

    7/857 2010 Progress Software Corporation7

    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

  • 8/10/2019 Intro Camel

    8/858 2010 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

  • 8/10/2019 Intro Camel

    9/85

    Wh i A h C l

  • 8/10/2019 Intro Camel

    10/85

    10 2010 Progress Software Corporation

    What is Apache Camel

    Quote from the web site

    10

    Apache Camel is a

    Powerful Open SourceIntegration Framework

    based on known

    Enterprise Integration Patterns

    Wh t i A h C l

  • 8/10/2019 Intro Camel

    11/85

    11 2010 Progress Software Corporation

    What is Apache Camel

    Why do we need Integration? Your apps are build using different tech stacks

    Critical for your business to integrate

    Why Integration Framework?

    Framework do the heavy lifting Focus on business problem

    Not "reinventing the wheel"

    11

    Wh t i A h C l

  • 8/10/2019 Intro Camel

    12/85

    12 2010 Progress Software Corporation

    What is Apache Camel

    What is Enterprise Integration Patterns?

    12

  • 8/10/2019 Intro Camel

    13/85

    What is Apache Camel

  • 8/10/2019 Intro Camel

    14/85

    14 2010 Progress Software Corporation

    What is Apache Camel

    What is Enterprise Integration Patterns?

    14

    Its a boo k

    What is Apache Camel

  • 8/10/2019 Intro Camel

    15/85

    15 2010 Progress Software Corporation

    What is Apache Camel

    Lets look at one of the patterns

    15

    What is Apache Camel

  • 8/10/2019 Intro Camel

    16/85

    16 2010 Progress Software Corporation

    What is Apache Camel

    Use Case

    16

    ActiveMQ WebSphereMQ

    What is Apache Camel

  • 8/10/2019 Intro Camel

    17/85

    17 2010 Progress Software Corporation

    What is Apache Camel

    Filter Pattern

    17

  • 8/10/2019 Intro Camel

    18/85

    What is Apache Camel

  • 8/10/2019 Intro Camel

    19/85

    19 2010 Progress Software Corporation

    What is Apache Camel

    Filter Pattern

    19

    from(A) to(B)filter(predicate)

  • 8/10/2019 Intro Camel

    20/85

  • 8/10/2019 Intro Camel

    21/85

    What is Apache Camel

  • 8/10/2019 Intro Camel

    22/85

    22 2010 Progress Software Corporation

    What is Apache Camel

    Filter Route

    22

    isWidget = xpath(/quote/product = widget);

    from(A).filter(isWidget).to(B);

    What is Apache Camel

  • 8/10/2019 Intro Camel

    23/85

    23 2010 Progress Software Corporation

    p

    Filter Route

    23

    Endpoint A = endpoint(activemq:queue:quote);

    Endpoint B = endpoint(mq:quote);

    Predicate isWidget = xpath(/quote/product = widget);

    from(A).filter(isWidget).to(B);

    What is Apache Camel

  • 8/10/2019 Intro Camel

    24/85

    24 2010 Progress Software Corporation

    p

    Filter Route - Java DSL

    24

    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);

    }

    What is Apache Camel

  • 8/10/2019 Intro Camel

    25/85

    25 2010 Progress Software Corporation

    p

    Filter Route - Java DSL

    25

    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);}

    }

    What is Apache Camel

  • 8/10/2019 Intro Camel

    26/85

    26 2010 Progress Software Corporation

    Filter Route - Java DSL

    26

    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");

    }

    }

    What is Apache Camel

  • 8/10/2019 Intro Camel

    27/85

    27 2010 Progress Software Corporation

    IDE Tooling

    27

    Code

    Assistance

    JavaDoc

    What is Apache Camel

  • 8/10/2019 Intro Camel

    28/85

    28 2010 Progress Software Corporation

    IDE Tooling

    28

    Code

    Assistance

    What is Apache Camel

  • 8/10/2019 Intro Camel

    29/85

    29 2010 Progress Software Corporation

    Lets look at the most famous pattern

    29

    What is Apache Camel

  • 8/10/2019 Intro Camel

    30/85

    30 2010 Progress Software Corporation

    Content Based Router

    30

    What is Apache Camel

  • 8/10/2019 Intro Camel

    31/85

    31 2010 Progress Software Corporation

    Content Based Router - Spring XML

    31

    /order/product = 'widget'

    What is Apache Camel

  • 8/10/2019 Intro Camel

    32/85

    32 2010 Progress Software Corporation

    Content Based Router - Java DSL

    32

    from("activemq:NewOrders")

    .choice()

    .when().xpath(/order/product = 'widget')

    .to(activemq:Orders.Widget)

    .otherwise()

    .to(acitvemq:Orders.Gadget);

    What is Apache Camel

  • 8/10/2019 Intro Camel

    33/85

    33 2010 Progress Software Corporation

    Summary

    Camel is an integration framework

    Based on Enterprise Integration Patterns

    Routing and mediation

    Easy to use DSL to define routes

    No heavy specification

    No container dependency

    Payload agnostic

    Connectivity to a great wealth of transports

    33

    What is Apache Camel

  • 8/10/2019 Intro Camel

    34/85

    34 2010 Progress Software Corporation

    Mission Statement

    34

    Making integration easier andmore accessible to developers

    Agenda

  • 8/10/2019 Intro Camel

    35/85

    35 2010 Progress Software Corporation35

    The birth of Apache Camel

    What is Apache Camel

    A little example

    What's included in the box?

    Running CamelAnother Example

    The Camel Community

    Q and A

  • 8/10/2019 Intro Camel

    36/85

    A little example

  • 8/10/2019 Intro Camel

    37/85

    37 2010 Progress Software Corporation37

    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

  • 8/10/2019 Intro Camel

    38/85

    A little example

  • 8/10/2019 Intro Camel

    39/85

    39 2010 Progress Software Corporation39

    Camel DSL in XML

    Agenda

  • 8/10/2019 Intro Camel

    40/85

    40 2010 Progress Software Corporation40

    The birth of Apache Camel

    What is Apache Camel

    A little example

    What's included in the box?

    Running CamelAnother Example

    The Camel Community

    Q and A

    What's included in the box?

  • 8/10/2019 Intro Camel

    41/85

    41 2010 Progress Software Corporation

    Highlights of whats included in Camel

    41

    What's included in the box?

  • 8/10/2019 Intro Camel

    42/85

    42 2010 Progress Software Corporation

    50+ EIP patterns

    42

    http://camel.apache.org/enterprise-integration-patterns.html

    What's included in the box?

  • 8/10/2019 Intro Camel

    43/85

    43 2010 Progress Software Corporation

    70+ Components

    43

    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

    What's included in the box?

    http://activemq.apache.org/camel/components.htmlhttp://activemq.apache.org/camel/components.html
  • 8/10/2019 Intro Camel

    44/85

    44 2010 Progress Software Corporation

    70+ Components

    44

    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

    What's included in the box?

    http://activemq.apache.org/camel/components.htmlhttp://activemq.apache.org/camel/components.html
  • 8/10/2019 Intro Camel

    45/85

    45 2010 Progress Software Corporation

    18 Data Formats

    45

    bindy protobuf

    castor serialization

    csv soap

    crypto tidy markupflatpack xml beans

    gzip xml security

    hl7 xstream

    jaxb zipjson dozer

    http://camel.apache.org/data-format.html

    What's included in the box?

    http://activemq.apache.org/camel/components.htmlhttp://activemq.apache.org/camel/components.htmlhttp://activemq.apache.org/camel/components.htmlhttp://activemq.apache.org/camel/components.html
  • 8/10/2019 Intro Camel

    46/85

    46 2010 Progress Software Corporation

    Data Format

    46

    from("activemq:QueueWithJavaObjects)

    .marshal().jaxb()

    .to("mq:QueueWithXmlMessages");

    What's included in the box?

  • 8/10/2019 Intro Camel

    47/85

    47 2010 Progress Software Corporation

    Predicates & Expressions

    47

    BeanShell PHP

    EL Python

    Groovy Ruby

    JavaScript Simple

    JSR 223 SQL

    OGNL XPath

    MVEL XQuery

    http://camel.apache.org/languages.html

    What's included in the box?

    http://camel.apache.org/languages.htmlhttp://camel.apache.org/languages.html
  • 8/10/2019 Intro Camel

    48/85

    48 2010 Progress Software Corporation

    DSL in 3 programming languages

    48

    from(A).filter(isWidget).to(B);

    from(A) filter(isWidget) --> B

    /quote/product = widget

    XMLJava

    Scala

    What's included in the box?

  • 8/10/2019 Intro Camel

    49/85

    49 2010 Progress Software Corporation

    Type Converters

    49

    INFO DefaultTypeConverter

    - Loaded 148 type converters

    What's included in the box?

  • 8/10/2019 Intro Camel

    50/85

    50 2010 Progress Software Corporation

    Custom Type Converters

    50

    # META-INF/services/org/apache/camel/TypeConverter

    com.acme.convertersMETA-INF file in the JAR

    @Converter

    public class MyTypeConverter {

    @Converter

    public String toString(MyOrder order) {StringBuilder sb = new StringBuilder();

    ...

    return sb.toString();

    }

    }

  • 8/10/2019 Intro Camel

    51/85

    What's included in the box?

  • 8/10/2019 Intro Camel

    52/85

    52 2010 Progress Software Corporation

    Bean as Message Translator

    52

    What's included in the box?

  • 8/10/2019 Intro Camel

    53/85

    53 2010 Progress Software Corporation

    Bean as Message Translator

    53

    public class Foo {

    public String someMethod(String name) {

    return Hello + name;}

    }

    from("activemq:Incoming).

    beanRef("myBeanName, someMethod").

    to("activemq:Outgoing");

    What's included in the box?

  • 8/10/2019 Intro Camel

    54/85

    54 2010 Progress Software Corporation

    Bean Parameter Binding with XPath

    54

    public class Foo {

    public String processOrder(

    String orderAsXml,

    @XPath(/order/@id") String oid,@Header("JMSCorrelationID") String cid) {

    ...

    }

    }

    What's included in the box?

  • 8/10/2019 Intro Camel

    55/85

    55 2010 Progress Software Corporation

    Sending message

    55

    public class Foo {

    @Produce(uri = "activemq:foo.bar")

    ProducerTemplate producer;

    public void doSomething() {

    if (whatEver) {

    producer.sendBody("Hello World");

    }

    }

    }

    What's included in the box?

  • 8/10/2019 Intro Camel

    56/85

    56 2010 Progress Software Corporation

    Receiving message

    56

    public class Foo {

    @Consume(uri = "activemq:cheese")

    public void onCheese(String name) {

    ...

    }

    }

    What's included in the box?

  • 8/10/2019 Intro Camel

    57/85

    57 2010 Progress Software Corporation

    Test Kit

    camel-test.jar

    JUnit based (3.x and 4.x)

    Supports Spring

    Easy to test

    Quick prototyping

    57

    What's included in the box?

  • 8/10/2019 Intro Camel

    58/85

    58 2010 Progress Software Corporation

    Test Kit from IDE

    58

    Right Click ->

    Run

    Debug

    extend CamelTestSupport

    Inline RouteBuilder

    What's included in the box?

  • 8/10/2019 Intro Camel

    59/85

    59 2010 Progress Software Corporation

    Managed

    JMX API

    REST API

    59

    What's included in the box?

  • 8/10/2019 Intro Camel

    60/85

    60 2010 Progress Software Corporation

    Web console

    REST API

    60

    What's included in the box?

  • 8/10/2019 Intro Camel

    61/85

    61 2010 Progress Software Corporation

    FuseSource Rider

    61

    What's included in the box?

  • 8/10/2019 Intro Camel

    62/85

    62 2010 Progress Software Corporation

    Summary

    50+ EIP patterns

    70+ Connectivity components

    15+ Data formats

    10+ Languages

    DSL in multiple flavors (Java, XML, Scala, Groovy) Automatic type conversion

    Strong bean support

    Test Kit

    Management (JMX, REST)

    Web console

    62

    Agenda

  • 8/10/2019 Intro Camel

    63/85

    63 2010 Progress Software Corporation63

    The birth of Apache Camel

    What is Apache Camel

    A little example

    What's included in the box?

    Running Camel

    Another Example

    The Camel Community

    Q and A

    Running Camel

  • 8/10/2019 Intro Camel

    64/85

    64 2010 Progress Software Corporation

    Riding the Camel

    64

    Running Camel

  • 8/10/2019 Intro Camel

    65/85

    65 2010 Progress Software Corporation

    Camel is not a server

    Camel is lightweight and embeddable

    Known Deployment Options

    Standalone Java Application

    Web Application

    J2EE Application

    JBI

    OSGi

    Google App Engine

    Java Web Start Spring Application

    65

    Known Containers

    Apache ServiceMix

    Apache ActiveMQ

    Apache Tomcat

    Jetty

    JBoss

    IBM WebSphere

    BEA WebLogic

    Oracle OC4j

    GAE... others

    Running Camel

  • 8/10/2019 Intro Camel

    66/85

    66 2010 Progress Software Corporation

    Java Application

    Spring Application

    66

    CamelContext context = new DefaultCamelContext();

    context.addRoutes(new MyRouteBuilder());

    context.start();

    com.acme.quotes

    Agenda

  • 8/10/2019 Intro Camel

    67/85

    67 2010 Progress Software Corporation

    The birth of Apache Camel

    What is Apache Camel

    A little example

    What's included in the box?

    Running Camel

    Another Example

    The Camel Community

    Q and A

    67

    Another Example

  • 8/10/2019 Intro Camel

    68/85

    68 2010 Progress Software Corporation

    Rider Auto Parts Example by Jonathan Anstey

    68

    http://architects.dzone.com/articles/apache-camel-integration

    Another Example

    http://architects.dzone.com/articles/apache-camel-integrationhttp://architects.dzone.com/articles/apache-camel-integrationhttp://architects.dzone.com/articles/apache-camel-integrationhttp://architects.dzone.com/articles/apache-camel-integrationhttp://architects.dzone.com/articles/apache-camel-integrationhttp://architects.dzone.com/articles/apache-camel-integration
  • 8/10/2019 Intro Camel

    69/85

    69 2010 Progress Software Corporation

    Rider Auto Parts Example - 3 Routes

    69

    1

    Another Example

  • 8/10/2019 Intro Camel

    70/85

    70 2010 Progress Software Corporation

    Rider Auto Parts Example - 3 Routes

    70

    2

    1

    Another Example

  • 8/10/2019 Intro Camel

    71/85

    71 2010 Progress Software Corporation

    Rider Auto Parts Example - 3 Routes

    71

    32

    1

    Another Example

  • 8/10/2019 Intro Camel

    72/85

    72 2010 Progress Software Corporation

    Rider Auto Parts Example - 1st Route

    72

    from

    to

    1

    public class Route1 extends RouteBuilder {

    public void configure() throws Exception {

    from("ftp:[email protected]?password=secret")

    .to("activemq:queue:incoming");

    }

    }

    Another Example

    mailto:[email protected]:[email protected]
  • 8/10/2019 Intro Camel

    73/85

    73 2010 Progress Software Corporation

    Rider Auto Parts Example - 2nd Route

    73

    tofrom

    public class Route2 extends RouteBuilder {

    public void configure() throws Exception {

    from("jetty:http://localhost:8080/orders")

    .inOnly("activemq:queue:incoming")

    .transform().constant("OK");

    }

    }

    2

    Another Example

  • 8/10/2019 Intro Camel

    74/85

    74 2010 Progress Software Corporation

    Rider Auto Parts Example - 3rd Route

    74

    from to

    choice

    3

    route on next slide

  • 8/10/2019 Intro Camel

    75/85

    Agenda

  • 8/10/2019 Intro Camel

    76/85

    76 2010 Progress Software Corporation

    76

    The birth of Apache Camel

    What is Apache Camel

    A little example

    What's included in the box?

    Running Camel

    Another Example

    The Camel Community

    Q and A

    The Camel Community

  • 8/10/2019 Intro Camel

    77/85

    77

    2010 Progress Software Corporation

    77

    Camel website

    52% increase (2010 over 2009)

    Average 2200 visits per weekday (2000 - 2500)

    High activity on mailing list

    The Camel Community

  • 8/10/2019 Intro Camel

    78/85

    78

    2010 Progress Software Corporation

    78

    20 committers

    High commit activity

    http://markmail.org/

    http://markmail.org/http://markmail.org/
  • 8/10/2019 Intro Camel

    79/85

  • 8/10/2019 Intro Camel

    80/85

    The Camel Community

  • 8/10/2019 Intro Camel

    81/85

    81 2010 Progress Software Corporation81

    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 278

    Camel 2.4 July 2010 182

    Camel 2.5 Sep 2010 170+

    The Camel Community

  • 8/10/2019 Intro Camel

    82/85

    82 2010 Progress Software Corporation82

    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

    JBoss Drools

    JBoss ESB

    In Progress

    Smooks

    Doozer

    Agenda

  • 8/10/2019 Intro Camel

    83/85

    83 2010 Progress Software Corporation83

    The birth of Apache Camel

    What is Apache Camel

    A little example

    What's included in the box?

    Running Camel

    Another Example

    The Camel Community

    Q and A

    Q and A

  • 8/10/2019 Intro Camel

    84/85

    84 2010 Progress Software Corporation84

    Where do I get more information?

    Camel website: http://camel.apache.orgCamel article: http://architects.dzone.com/articles/apache-camel-integration

    FuseSource website: http://fusesource.com

    Camel in Action book: http://manning.com/ibsen

    Q and A

    http://camel.apache.org/http://architects.dzone.com/articles/apache-camel-integrationhttp://fusesource.com/http://manning.com/ibsenhttp://manning.com/ibsenhttp://fusesource.com/http://architects.dzone.com/articles/apache-camel-integrationhttp://architects.dzone.com/articles/apache-camel-integrationhttp://architects.dzone.com/articles/apache-camel-integrationhttp://architects.dzone.com/articles/apache-camel-integrationhttp://architects.dzone.com/articles/apache-camel-integrationhttp://camel.apache.org/
  • 8/10/2019 Intro Camel

    85/85

    85 2010 Progress Software Corporation85