SlideShare a Scribd company logo
1 of 43
Download to read offline
Taking Apache Camel
     For a Ride




        Bruce Snyder
     bsnyder@apache.org
         3 June 2008      1
Integration is Messy!




                        2
System Integration




                     3
Data Formats




               4
Apache Camel




        http://activemq.apache.org/camel/
                                            5
What is
Apache
Camel?
          6
Enterprise Integration Patterns




          http://enterpriseintegrationpatterns.com/

                                                      7
Patterns




           8
Message Routing




                  9
Language Support


 •   BeanShell     •   SQL
 •   Javascript    •   XPath
 •   Groovy        •   XQuery
 •   Python        •   OGNL
 •   PHP           •   JSR 223 scripting
 •   Ruby




                                           10
Apache Camel Components




       http://activemq.apache.org/camel/components.html



                                                          11
History of Apache Camel




                          12
The Camel Context



CamelContext context = new DefaultCamelContext();
context.addRoutes(new MyRouteBuilder());
context.start();




<camelContext
  xmlns=quot;http://activemq.apache.org/camel/schema/springquot;>
  <package>com.acme.quotes</package>
</camelContext>




                                                            13
Pattern
Examples
           14
Patterns Again




                 15
Content Based Router




  RouteBuilder builder = new RouteBuilder() {
 public void configure() {
   from(quot;seda:aquot;).choice().when(header(quot;fooquot;)
      .isEqualTo(quot;barquot;)).to(quot;seda:bquot;)
        .when(header(quot;fooquot;).isEqualTo(quot;cheesequot;))
          .to(quot;seda:cquot;).otherwise().to(quot;seda:dquot;);
        }
   };


                                                    16
Content Based Router

  <camelContext
    xmlns=quot;http://activemq.apache.org/camel/schema/springquot;>
    <route>
      <from uri=quot;activemq:NewOrdersquot;/>
      <choice>
        <when>
          <xpath>/order/product = 'widget'</xpath>
          <to uri=quot;activemq:Orders.Widgetsquot;/>
        </when>
        <when>
          <xpath>/order/product = 'gadget'</xpath>
          <to uri=quot;activemq:Orders.Gadgetsquot;/>
        </when>
        <otherwise>
          <to uri=quot;activemq:Orders.Badquot;/>
        </otherwise>
      </choice>
    </route>
  </camelContext>



                                                              17
Message Filter




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
        from(quot;activemq:topic:Quotes).
            filter().xpath(quot;/quote/product = ‘widget’quot;).
                to(quot;mqseries:WidgetQuotesquot;);
  }
}




                                                           18
Message Filter

 <camelContext
   xmlns=quot;http://activemq.apache.org/camel/schema/springquot;>
     <route>
       <from uri=quot;activemq:topic:Quotesquot;/>
       <filter>
         <xpath>/quote/product = ‘widget’</xpath>
         <to uri=quot;mqseries:WidgetQuotesquot;/>
       </filter>
     </route>
   </camelContext>




                                                             19
Splitter




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;file://ordersquot;).
        splitter(body().tokenize(quot;nquot;)).
          to(quot;activemq:Order.Itemsquot;);
    }
  }


                                                     20
Splitter Using XQuery



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;file://ordersquot;).
        splitter().xquery(quot;/order/itemsquot;).
          to(quot;activemq:Order.Itemsquot;);
    }
  }




                                                     21
Aggregator




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;activemq:Inventory.Itemsquot;).
        aggregator().xpath(quot;/order/@idquot;).
          to(quot;activemq:Inventory.Orderquot;);
    }
  }




                                                     22
Message Translator




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;file://incoming”).
        to(quot;xslt:com/acme/mytransform.xslquot;).
          to(quot;http://outgoing.com/fooquot;);
    }
  }




                                                     23
Resequencer




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;direct:a”).
        resequencer(header(quot;JMSPriorityquot;)).
          to(quot;seda:bquot;);
    }
  }



                                                     24
Throttler



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;seda:a”).
        throttler(3).timePeriodMillis(30000).
          to(quot;seda:bquot;);
    }
  }




                                                     25
Delayer



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;seda:a”).
        delayer(header(quot;JMSTimestampquot;, 3000).
          to(quot;seda:bquot;);
    }
  }




                                                     26
Combine Patterns



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;seda:a”).
        resequencer(header(quot;JMSPriorityquot;)).
        delayer(3000).
          to(quot;seda:bquot;);
    }
  }




                                                     27
Beans




        28
Bean


  package com.mycompany.beans;

  public class MyBean {

      public void someMethod(String name) {
        ...
      }
  }



<camelContext
  xmlns=quot;http://activemq.apache.org/camel/schema/springquot;>
  <package>com.mycompany.beans</package>
</camelContext>



                                                            29
Bean as a Message Translator



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;activemq:Incoming”).
        beanRef(quot;myBeanquot;).
          to(quot;activemq:Outgoingquot;);
    }
  }




                                                     30
Bean as a Message Translator


 *With Method Name


   public class MyRouteBuilder extends RouteBuilder {
       public void configure() {
           from(quot;activemq:Incoming”).
             beanRef(quot;myBeanquot;, quot;someMethodquot;).
               to(quot;activemq:Outgoingquot;);
       }
   }




                                                        31
Type Conversion




                  32
Type Conversion

@Converter
public class IOConverter {

    @Converter
    public static InputStream toInputStream(File file)
      throws FileNotFoundException {
        return new BufferedInputStream(
          new FileInputStream(file));
      }
}




                                                         33
Binding Beans to Camel Endpoints

public class Foo {

    @MessageDriven(uri=quot;activemq:cheesequot;)
    public void onCheese(String name) {
      ...
    }
}




                                            34
Binding Method Arguments

public class Foo {

    public void onCheese(
      @XPath(quot;/foo/barquot;) String name,
      @Header(quot;JMSCorrelationIDquot;) String id) {
      ...
    }
}




            http://activemq.apache.org/camel/bean-integration.html


                                                                     35
Injecting Endpoints Into Beans


  public class Foo {
    @EndpointInject(uri=quot;activemq:foo.barquot;)
    ProducerTemplate producer;

      public void doSomething() {
        if (whatever) {
          producer.sendBody(quot;<hello>world!</hello>quot;);
        }
      }
  }




                                                        36
Spring Remoting - Server Side


 <camelContext
   xmlns=quot;http://activemq.apache.org/camel/schema/springquot;>
   <export id=quot;sayServicequot;
     uri=quot;activemq:MyServicequot;
     serviceRef=quot;sayImplquot;
     serviceInterface=quot;com.acme.MyServiceInterfacequot;/>
 </camelContext>

 <bean id=quot;sayImplquot; class=quot;com.acme.MyServiceImplquot;/>




                                                             37
Spring Remoting - Client Side


 <camelContext
   xmlns=quot;http://activemq.apache.org/camel/schema/springquot;>
   <proxy id=quot;sayServicequot; serviceUrl=quot;activemq:MyServicequot;
     serviceInterface=quot;com.acme.MyServiceInterfacequot;/>
 </camelContext>




                                                             38
Dependency Injection

<camelContext
  xmlns=quot;http://activemq.apache.org/camel/schema/springquot;>
  ...
</camelContext>

<bean id=quot;activemqquot;
  class=quot;org.apache.camel.component.jms.JmsComponentquot;>
  <property name=quot;connectionFactoryquot;>
    <bean class=quot;org.apache.activemq.ActiveMQConnectionFactoryquot;>
      <property name=quot;brokerURLquot;
                value=quot;vm://localhost?broker.persistent=falsequot;/>
    </bean>
  </property>
</bean>




                                                                   39
Business Activity Monitoring (BAM)




                                     40
Business Activity Monitoring (BAM)


public class MyActivities extends ProcessBuilder {

    public void configure() throws Exception {

        // lets define some activities, correlating on an
        // XPath query of the message body
        ActivityBuilder purchaseOrder = activity(quot;activemq:PurchaseOrdersquot;)
                .correlate(xpath(quot;/purchaseOrder/@idquot;).stringResult());

        ActivityBuilder invoice = activity(quot;activemq:Invoicesquot;)
                .correlate(xpath(quot;/invoice/@purchaseOrderIdquot;).stringResult());

        // now lets add some BAM rules
        invoice.starts().after(purchaseOrder.completes())
                .expectWithin(seconds(1))
                .errorIfOver(seconds(2)).to(quot;activemq:FailedProcessesquot;);
    }
}




                                                                                 41
Ride the Camel!




                  42
Questions?




             43

More Related Content

What's hot

Developing Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containersDeveloping Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containersClaus Ibsen
 
Integration made easy with Apache Camel
Integration made easy with Apache CamelIntegration made easy with Apache Camel
Integration made easy with Apache CamelRosen Spasov
 
Getting Started with Apache Camel at DevNation 2014
Getting Started with Apache Camel at DevNation 2014Getting Started with Apache Camel at DevNation 2014
Getting Started with Apache Camel at DevNation 2014Claus Ibsen
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camelkrasserm
 
Apache Camel K - Copenhagen
Apache Camel K - CopenhagenApache Camel K - Copenhagen
Apache Camel K - CopenhagenClaus Ibsen
 
Integration using Apache Camel and Groovy
Integration using Apache Camel and GroovyIntegration using Apache Camel and Groovy
Integration using Apache Camel and GroovyClaus Ibsen
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringJoe Kutner
 
State of integration with Apache Camel (ApacheCon 2019)
State of integration with Apache Camel (ApacheCon 2019)State of integration with Apache Camel (ApacheCon 2019)
State of integration with Apache Camel (ApacheCon 2019)Claus Ibsen
 
Apache Camel K - Fredericia
Apache Camel K - FredericiaApache Camel K - Fredericia
Apache Camel K - FredericiaClaus Ibsen
 
Java Play RESTful ebean
Java Play RESTful ebeanJava Play RESTful ebean
Java Play RESTful ebeanFaren faren
 
Java Play Restful JPA
Java Play Restful JPAJava Play Restful JPA
Java Play Restful JPAFaren faren
 
Getting Started with Apache Camel - Devconf Conference - February 2013
Getting Started with Apache Camel - Devconf Conference - February 2013Getting Started with Apache Camel - Devconf Conference - February 2013
Getting Started with Apache Camel - Devconf Conference - February 2013Claus Ibsen
 
Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...All Things Open
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsSadayuki Furuhashi
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Oscar Renalias
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play appsYevgeniy Brikman
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 
Getting started with Apache Camel - Javagruppen Copenhagen - April 2014
Getting started with Apache Camel - Javagruppen Copenhagen - April 2014Getting started with Apache Camel - Javagruppen Copenhagen - April 2014
Getting started with Apache Camel - Javagruppen Copenhagen - April 2014Claus Ibsen
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akkanartamonov
 

What's hot (20)

Developing Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containersDeveloping Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containers
 
Integration made easy with Apache Camel
Integration made easy with Apache CamelIntegration made easy with Apache Camel
Integration made easy with Apache Camel
 
Getting Started with Apache Camel at DevNation 2014
Getting Started with Apache Camel at DevNation 2014Getting Started with Apache Camel at DevNation 2014
Getting Started with Apache Camel at DevNation 2014
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camel
 
Apache Camel K - Copenhagen
Apache Camel K - CopenhagenApache Camel K - Copenhagen
Apache Camel K - Copenhagen
 
Integration using Apache Camel and Groovy
Integration using Apache Camel and GroovyIntegration using Apache Camel and Groovy
Integration using Apache Camel and Groovy
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and Spring
 
State of integration with Apache Camel (ApacheCon 2019)
State of integration with Apache Camel (ApacheCon 2019)State of integration with Apache Camel (ApacheCon 2019)
State of integration with Apache Camel (ApacheCon 2019)
 
Apache Camel K - Fredericia
Apache Camel K - FredericiaApache Camel K - Fredericia
Apache Camel K - Fredericia
 
Java Play RESTful ebean
Java Play RESTful ebeanJava Play RESTful ebean
Java Play RESTful ebean
 
Java Play Restful JPA
Java Play Restful JPAJava Play Restful JPA
Java Play Restful JPA
 
Getting Started with Apache Camel - Devconf Conference - February 2013
Getting Started with Apache Camel - Devconf Conference - February 2013Getting Started with Apache Camel - Devconf Conference - February 2013
Getting Started with Apache Camel - Devconf Conference - February 2013
 
Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play apps
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
Getting started with Apache Camel - Javagruppen Copenhagen - April 2014
Getting started with Apache Camel - Javagruppen Copenhagen - April 2014Getting started with Apache Camel - Javagruppen Copenhagen - April 2014
Getting started with Apache Camel - Javagruppen Copenhagen - April 2014
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akka
 
Scala active record
Scala active recordScala active record
Scala active record
 

Similar to DOSUG Taking Apache Camel For A Ride

Taking Apache Camel For a Ride
Taking Apache Camel For a RideTaking Apache Camel For a Ride
Taking Apache Camel For a RideBruce Snyder
 
Using Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel JockeyUsing Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel JockeyBruce Snyder
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A RideBruce Snyder
 
Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19confluent
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsJudy Breedlove
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworksEric Guo
 
G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門Tsuyoshi Yamamoto
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenJoshua Long
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixBruce Snyder
 
Service Oriented Integration with ServiceMix
Service Oriented Integration with ServiceMixService Oriented Integration with ServiceMix
Service Oriented Integration with ServiceMixghessler
 
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsIMC Institute
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'sAntônio Roberto Silva
 
Spring-training-in-bangalore
Spring-training-in-bangaloreSpring-training-in-bangalore
Spring-training-in-bangaloreTIB Academy
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5Martin Kleppe
 
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code ExampleMaven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code ExampleNikhil Bhalwankar
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSuzquiano
 
Testing microservices: Tools and Frameworks
Testing microservices: Tools and FrameworksTesting microservices: Tools and Frameworks
Testing microservices: Tools and FrameworksPiotr Mińkowski
 

Similar to DOSUG Taking Apache Camel For A Ride (20)

Taking Apache Camel For a Ride
Taking Apache Camel For a RideTaking Apache Camel For a Ride
Taking Apache Camel For a Ride
 
Using Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel JockeyUsing Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel Jockey
 
Aimaf
AimafAimaf
Aimaf
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A Ride
 
Riding Apache Camel
Riding Apache CamelRiding Apache Camel
Riding Apache Camel
 
Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworks
 
G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in Heaven
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
 
Service Oriented Integration with ServiceMix
Service Oriented Integration with ServiceMixService Oriented Integration with ServiceMix
Service Oriented Integration with ServiceMix
 
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom Tags
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Spring-training-in-bangalore
Spring-training-in-bangaloreSpring-training-in-bangalore
Spring-training-in-bangalore
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
 
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code ExampleMaven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
Testing microservices: Tools and Frameworks
Testing microservices: Tools and FrameworksTesting microservices: Tools and Frameworks
Testing microservices: Tools and Frameworks
 
lecture5
lecture5lecture5
lecture5
 

More from Matthew McCullough

iPhone & Java Web Services, Take 2
iPhone & Java Web Services, Take 2iPhone & Java Web Services, Take 2
iPhone & Java Web Services, Take 2Matthew McCullough
 
Git - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCSGit - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCSMatthew McCullough
 
Terracotta Java Scalability - Stateless Versus Stateful Apps
Terracotta Java Scalability - Stateless Versus Stateful AppsTerracotta Java Scalability - Stateless Versus Stateful Apps
Terracotta Java Scalability - Stateless Versus Stateful AppsMatthew McCullough
 
DOSUG GridGain Java Grid Computing Made Simple
DOSUG GridGain Java Grid Computing Made SimpleDOSUG GridGain Java Grid Computing Made Simple
DOSUG GridGain Java Grid Computing Made SimpleMatthew McCullough
 
DOSUG Intro to JQuery JavaScript Framework
DOSUG Intro to JQuery JavaScript FrameworkDOSUG Intro to JQuery JavaScript Framework
DOSUG Intro to JQuery JavaScript FrameworkMatthew McCullough
 
DOSUG Java FX Script From Takeoff To Cruising Altitude
DOSUG Java FX Script From Takeoff To Cruising AltitudeDOSUG Java FX Script From Takeoff To Cruising Altitude
DOSUG Java FX Script From Takeoff To Cruising AltitudeMatthew McCullough
 
DOSUG XML Beans overview by Om Sivanesian
DOSUG XML Beans overview by Om SivanesianDOSUG XML Beans overview by Om Sivanesian
DOSUG XML Beans overview by Om SivanesianMatthew McCullough
 

More from Matthew McCullough (11)

iPhone & Java Web Services, Take 2
iPhone & Java Web Services, Take 2iPhone & Java Web Services, Take 2
iPhone & Java Web Services, Take 2
 
iPhone & Java Web Services
iPhone & Java Web ServicesiPhone & Java Web Services
iPhone & Java Web Services
 
Git - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCSGit - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCS
 
Terracotta Java Scalability - Stateless Versus Stateful Apps
Terracotta Java Scalability - Stateless Versus Stateful AppsTerracotta Java Scalability - Stateless Versus Stateful Apps
Terracotta Java Scalability - Stateless Versus Stateful Apps
 
DOSUG GridGain Java Grid Computing Made Simple
DOSUG GridGain Java Grid Computing Made SimpleDOSUG GridGain Java Grid Computing Made Simple
DOSUG GridGain Java Grid Computing Made Simple
 
DOSUG Intro to JQuery JavaScript Framework
DOSUG Intro to JQuery JavaScript FrameworkDOSUG Intro to JQuery JavaScript Framework
DOSUG Intro to JQuery JavaScript Framework
 
DOSUG Wicket 101
DOSUG Wicket 101DOSUG Wicket 101
DOSUG Wicket 101
 
EasyMock 101
EasyMock 101EasyMock 101
EasyMock 101
 
DOSUG Java FX Script From Takeoff To Cruising Altitude
DOSUG Java FX Script From Takeoff To Cruising AltitudeDOSUG Java FX Script From Takeoff To Cruising Altitude
DOSUG Java FX Script From Takeoff To Cruising Altitude
 
DOSUG XML Beans overview by Om Sivanesian
DOSUG XML Beans overview by Om SivanesianDOSUG XML Beans overview by Om Sivanesian
DOSUG XML Beans overview by Om Sivanesian
 
DOSUG Tech Overview of XAware
DOSUG Tech Overview of XAwareDOSUG Tech Overview of XAware
DOSUG Tech Overview of XAware
 

Recently uploaded

how to exchange pi coins for USD in 2024.
how to exchange pi coins for USD in 2024.how to exchange pi coins for USD in 2024.
how to exchange pi coins for USD in 2024.DOT TECH
 
Prezentacja Q1 2024 EN strona www relacji
Prezentacja Q1 2024  EN strona www relacjiPrezentacja Q1 2024  EN strona www relacji
Prezentacja Q1 2024 EN strona www relacjiklaudiafilka
 
一比一原版(Cornell毕业证书)康奈尔大学毕业证成绩单学位证书
一比一原版(Cornell毕业证书)康奈尔大学毕业证成绩单学位证书一比一原版(Cornell毕业证书)康奈尔大学毕业证成绩单学位证书
一比一原版(Cornell毕业证书)康奈尔大学毕业证成绩单学位证书atedyxc
 
一比一原版(UC Davis毕业证书)加州大学戴维斯分校毕业证成绩单学位证书
一比一原版(UC Davis毕业证书)加州大学戴维斯分校毕业证成绩单学位证书一比一原版(UC Davis毕业证书)加州大学戴维斯分校毕业证成绩单学位证书
一比一原版(UC Davis毕业证书)加州大学戴维斯分校毕业证成绩单学位证书atedyxc
 
What exchange can I sell my pi coins in 2024
What exchange can I sell my pi coins in 2024What exchange can I sell my pi coins in 2024
What exchange can I sell my pi coins in 2024DOT TECH
 
What is an ecosystem in crypto .pdf
What  is  an  ecosystem  in  crypto .pdfWhat  is  an  ecosystem  in  crypto .pdf
What is an ecosystem in crypto .pdfKezex (KZX)
 
Top 5 Asset Baked Tokens (ABT) to Invest in the Year 2024.pdf
Top 5 Asset Baked Tokens (ABT) to Invest in the Year 2024.pdfTop 5 Asset Baked Tokens (ABT) to Invest in the Year 2024.pdf
Top 5 Asset Baked Tokens (ABT) to Invest in the Year 2024.pdfcoingabbar
 
how do I cash out pi network coin in 2024.
how do I cash out pi network coin in 2024.how do I cash out pi network coin in 2024.
how do I cash out pi network coin in 2024.DOT TECH
 
一比一原版(KPU毕业证书)昆特兰理工大学毕业证成绩单学位证书
一比一原版(KPU毕业证书)昆特兰理工大学毕业证成绩单学位证书一比一原版(KPU毕业证书)昆特兰理工大学毕业证成绩单学位证书
一比一原版(KPU毕业证书)昆特兰理工大学毕业证成绩单学位证书atedyxc
 
NO1 Popular Black magic specialist,Expert in Pakistan Amil Baba kala ilam Exp...
NO1 Popular Black magic specialist,Expert in Pakistan Amil Baba kala ilam Exp...NO1 Popular Black magic specialist,Expert in Pakistan Amil Baba kala ilam Exp...
NO1 Popular Black magic specialist,Expert in Pakistan Amil Baba kala ilam Exp...Amil Baba Dawood bangali
 
New Stratus Corporate Presentation May 2024
New Stratus Corporate Presentation May 2024New Stratus Corporate Presentation May 2024
New Stratus Corporate Presentation May 2024Adnet Communications
 
Population Growth and Economic Development
Population Growth and  Economic DevelopmentPopulation Growth and  Economic Development
Population Growth and Economic Developmentyirgalemleaye
 
NO1 Best kala jadu karne wale ka contact number kala jadu karne wale baba kal...
NO1 Best kala jadu karne wale ka contact number kala jadu karne wale baba kal...NO1 Best kala jadu karne wale ka contact number kala jadu karne wale baba kal...
NO1 Best kala jadu karne wale ka contact number kala jadu karne wale baba kal...Amil baba
 
Consumer rights and its importance and value
Consumer rights and its importance and valueConsumer rights and its importance and value
Consumer rights and its importance and valuehemalella
 
Goldamn report on India's economy in 2024
Goldamn report on India's economy in 2024Goldamn report on India's economy in 2024
Goldamn report on India's economy in 2024ssuser7d2330
 
一比一原版(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单学位证书
一比一原版(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单学位证书一比一原版(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单学位证书
一比一原版(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单学位证书atedyxc
 
how do i sell pi coins in Pakistan at the best rate.
how do i sell pi coins in Pakistan at the best rate.how do i sell pi coins in Pakistan at the best rate.
how do i sell pi coins in Pakistan at the best rate.DOT TECH
 
Zepto Case study(On Track to Profitability).pptx
Zepto Case study(On Track to Profitability).pptxZepto Case study(On Track to Profitability).pptx
Zepto Case study(On Track to Profitability).pptxaryan963438
 
Fintech Belgium General Assembly and Anniversary Event 2024
Fintech Belgium General Assembly and Anniversary Event 2024Fintech Belgium General Assembly and Anniversary Event 2024
Fintech Belgium General Assembly and Anniversary Event 2024FinTech Belgium
 

Recently uploaded (20)

how to exchange pi coins for USD in 2024.
how to exchange pi coins for USD in 2024.how to exchange pi coins for USD in 2024.
how to exchange pi coins for USD in 2024.
 
Prezentacja Q1 2024 EN strona www relacji
Prezentacja Q1 2024  EN strona www relacjiPrezentacja Q1 2024  EN strona www relacji
Prezentacja Q1 2024 EN strona www relacji
 
一比一原版(Cornell毕业证书)康奈尔大学毕业证成绩单学位证书
一比一原版(Cornell毕业证书)康奈尔大学毕业证成绩单学位证书一比一原版(Cornell毕业证书)康奈尔大学毕业证成绩单学位证书
一比一原版(Cornell毕业证书)康奈尔大学毕业证成绩单学位证书
 
一比一原版(UC Davis毕业证书)加州大学戴维斯分校毕业证成绩单学位证书
一比一原版(UC Davis毕业证书)加州大学戴维斯分校毕业证成绩单学位证书一比一原版(UC Davis毕业证书)加州大学戴维斯分校毕业证成绩单学位证书
一比一原版(UC Davis毕业证书)加州大学戴维斯分校毕业证成绩单学位证书
 
What exchange can I sell my pi coins in 2024
What exchange can I sell my pi coins in 2024What exchange can I sell my pi coins in 2024
What exchange can I sell my pi coins in 2024
 
What is an ecosystem in crypto .pdf
What  is  an  ecosystem  in  crypto .pdfWhat  is  an  ecosystem  in  crypto .pdf
What is an ecosystem in crypto .pdf
 
Top 5 Asset Baked Tokens (ABT) to Invest in the Year 2024.pdf
Top 5 Asset Baked Tokens (ABT) to Invest in the Year 2024.pdfTop 5 Asset Baked Tokens (ABT) to Invest in the Year 2024.pdf
Top 5 Asset Baked Tokens (ABT) to Invest in the Year 2024.pdf
 
how do I cash out pi network coin in 2024.
how do I cash out pi network coin in 2024.how do I cash out pi network coin in 2024.
how do I cash out pi network coin in 2024.
 
Canvas Business Model Infographics by Slidesgo.pptx
Canvas Business Model Infographics by Slidesgo.pptxCanvas Business Model Infographics by Slidesgo.pptx
Canvas Business Model Infographics by Slidesgo.pptx
 
一比一原版(KPU毕业证书)昆特兰理工大学毕业证成绩单学位证书
一比一原版(KPU毕业证书)昆特兰理工大学毕业证成绩单学位证书一比一原版(KPU毕业证书)昆特兰理工大学毕业证成绩单学位证书
一比一原版(KPU毕业证书)昆特兰理工大学毕业证成绩单学位证书
 
NO1 Popular Black magic specialist,Expert in Pakistan Amil Baba kala ilam Exp...
NO1 Popular Black magic specialist,Expert in Pakistan Amil Baba kala ilam Exp...NO1 Popular Black magic specialist,Expert in Pakistan Amil Baba kala ilam Exp...
NO1 Popular Black magic specialist,Expert in Pakistan Amil Baba kala ilam Exp...
 
New Stratus Corporate Presentation May 2024
New Stratus Corporate Presentation May 2024New Stratus Corporate Presentation May 2024
New Stratus Corporate Presentation May 2024
 
Population Growth and Economic Development
Population Growth and  Economic DevelopmentPopulation Growth and  Economic Development
Population Growth and Economic Development
 
NO1 Best kala jadu karne wale ka contact number kala jadu karne wale baba kal...
NO1 Best kala jadu karne wale ka contact number kala jadu karne wale baba kal...NO1 Best kala jadu karne wale ka contact number kala jadu karne wale baba kal...
NO1 Best kala jadu karne wale ka contact number kala jadu karne wale baba kal...
 
Consumer rights and its importance and value
Consumer rights and its importance and valueConsumer rights and its importance and value
Consumer rights and its importance and value
 
Goldamn report on India's economy in 2024
Goldamn report on India's economy in 2024Goldamn report on India's economy in 2024
Goldamn report on India's economy in 2024
 
一比一原版(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单学位证书
一比一原版(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单学位证书一比一原版(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单学位证书
一比一原版(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单学位证书
 
how do i sell pi coins in Pakistan at the best rate.
how do i sell pi coins in Pakistan at the best rate.how do i sell pi coins in Pakistan at the best rate.
how do i sell pi coins in Pakistan at the best rate.
 
Zepto Case study(On Track to Profitability).pptx
Zepto Case study(On Track to Profitability).pptxZepto Case study(On Track to Profitability).pptx
Zepto Case study(On Track to Profitability).pptx
 
Fintech Belgium General Assembly and Anniversary Event 2024
Fintech Belgium General Assembly and Anniversary Event 2024Fintech Belgium General Assembly and Anniversary Event 2024
Fintech Belgium General Assembly and Anniversary Event 2024
 

DOSUG Taking Apache Camel For A Ride

  • 1. Taking Apache Camel For a Ride Bruce Snyder bsnyder@apache.org 3 June 2008 1
  • 5. Apache Camel http://activemq.apache.org/camel/ 5
  • 7. Enterprise Integration Patterns http://enterpriseintegrationpatterns.com/ 7
  • 10. Language Support • BeanShell • SQL • Javascript • XPath • Groovy • XQuery • Python • OGNL • PHP • JSR 223 scripting • Ruby 10
  • 11. Apache Camel Components http://activemq.apache.org/camel/components.html 11
  • 12. History of Apache Camel 12
  • 13. The Camel Context CamelContext context = new DefaultCamelContext(); context.addRoutes(new MyRouteBuilder()); context.start(); <camelContext xmlns=quot;http://activemq.apache.org/camel/schema/springquot;> <package>com.acme.quotes</package> </camelContext> 13
  • 16. Content Based Router RouteBuilder builder = new RouteBuilder() { public void configure() { from(quot;seda:aquot;).choice().when(header(quot;fooquot;) .isEqualTo(quot;barquot;)).to(quot;seda:bquot;) .when(header(quot;fooquot;).isEqualTo(quot;cheesequot;)) .to(quot;seda:cquot;).otherwise().to(quot;seda:dquot;); } }; 16
  • 17. Content Based Router <camelContext xmlns=quot;http://activemq.apache.org/camel/schema/springquot;> <route> <from uri=quot;activemq:NewOrdersquot;/> <choice> <when> <xpath>/order/product = 'widget'</xpath> <to uri=quot;activemq:Orders.Widgetsquot;/> </when> <when> <xpath>/order/product = 'gadget'</xpath> <to uri=quot;activemq:Orders.Gadgetsquot;/> </when> <otherwise> <to uri=quot;activemq:Orders.Badquot;/> </otherwise> </choice> </route> </camelContext> 17
  • 18. Message Filter public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;activemq:topic:Quotes). filter().xpath(quot;/quote/product = ‘widget’quot;). to(quot;mqseries:WidgetQuotesquot;); } } 18
  • 19. Message Filter <camelContext xmlns=quot;http://activemq.apache.org/camel/schema/springquot;> <route> <from uri=quot;activemq:topic:Quotesquot;/> <filter> <xpath>/quote/product = ‘widget’</xpath> <to uri=quot;mqseries:WidgetQuotesquot;/> </filter> </route> </camelContext> 19
  • 20. Splitter public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;file://ordersquot;). splitter(body().tokenize(quot;nquot;)). to(quot;activemq:Order.Itemsquot;); } } 20
  • 21. Splitter Using XQuery public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;file://ordersquot;). splitter().xquery(quot;/order/itemsquot;). to(quot;activemq:Order.Itemsquot;); } } 21
  • 22. Aggregator public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;activemq:Inventory.Itemsquot;). aggregator().xpath(quot;/order/@idquot;). to(quot;activemq:Inventory.Orderquot;); } } 22
  • 23. Message Translator public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;file://incoming”). to(quot;xslt:com/acme/mytransform.xslquot;). to(quot;http://outgoing.com/fooquot;); } } 23
  • 24. Resequencer public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;direct:a”). resequencer(header(quot;JMSPriorityquot;)). to(quot;seda:bquot;); } } 24
  • 25. Throttler public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;seda:a”). throttler(3).timePeriodMillis(30000). to(quot;seda:bquot;); } } 25
  • 26. Delayer public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;seda:a”). delayer(header(quot;JMSTimestampquot;, 3000). to(quot;seda:bquot;); } } 26
  • 27. Combine Patterns public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;seda:a”). resequencer(header(quot;JMSPriorityquot;)). delayer(3000). to(quot;seda:bquot;); } } 27
  • 28. Beans 28
  • 29. Bean package com.mycompany.beans; public class MyBean { public void someMethod(String name) { ... } } <camelContext xmlns=quot;http://activemq.apache.org/camel/schema/springquot;> <package>com.mycompany.beans</package> </camelContext> 29
  • 30. Bean as a Message Translator public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;activemq:Incoming”). beanRef(quot;myBeanquot;). to(quot;activemq:Outgoingquot;); } } 30
  • 31. Bean as a Message Translator *With Method Name public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;activemq:Incoming”). beanRef(quot;myBeanquot;, quot;someMethodquot;). to(quot;activemq:Outgoingquot;); } } 31
  • 33. Type Conversion @Converter public class IOConverter { @Converter public static InputStream toInputStream(File file) throws FileNotFoundException { return new BufferedInputStream( new FileInputStream(file)); } } 33
  • 34. Binding Beans to Camel Endpoints public class Foo { @MessageDriven(uri=quot;activemq:cheesequot;) public void onCheese(String name) { ... } } 34
  • 35. Binding Method Arguments public class Foo { public void onCheese( @XPath(quot;/foo/barquot;) String name, @Header(quot;JMSCorrelationIDquot;) String id) { ... } } http://activemq.apache.org/camel/bean-integration.html 35
  • 36. Injecting Endpoints Into Beans public class Foo { @EndpointInject(uri=quot;activemq:foo.barquot;) ProducerTemplate producer; public void doSomething() { if (whatever) { producer.sendBody(quot;<hello>world!</hello>quot;); } } } 36
  • 37. Spring Remoting - Server Side <camelContext xmlns=quot;http://activemq.apache.org/camel/schema/springquot;> <export id=quot;sayServicequot; uri=quot;activemq:MyServicequot; serviceRef=quot;sayImplquot; serviceInterface=quot;com.acme.MyServiceInterfacequot;/> </camelContext> <bean id=quot;sayImplquot; class=quot;com.acme.MyServiceImplquot;/> 37
  • 38. Spring Remoting - Client Side <camelContext xmlns=quot;http://activemq.apache.org/camel/schema/springquot;> <proxy id=quot;sayServicequot; serviceUrl=quot;activemq:MyServicequot; serviceInterface=quot;com.acme.MyServiceInterfacequot;/> </camelContext> 38
  • 39. Dependency Injection <camelContext xmlns=quot;http://activemq.apache.org/camel/schema/springquot;> ... </camelContext> <bean id=quot;activemqquot; class=quot;org.apache.camel.component.jms.JmsComponentquot;> <property name=quot;connectionFactoryquot;> <bean class=quot;org.apache.activemq.ActiveMQConnectionFactoryquot;> <property name=quot;brokerURLquot; value=quot;vm://localhost?broker.persistent=falsequot;/> </bean> </property> </bean> 39
  • 41. Business Activity Monitoring (BAM) public class MyActivities extends ProcessBuilder { public void configure() throws Exception { // lets define some activities, correlating on an // XPath query of the message body ActivityBuilder purchaseOrder = activity(quot;activemq:PurchaseOrdersquot;) .correlate(xpath(quot;/purchaseOrder/@idquot;).stringResult()); ActivityBuilder invoice = activity(quot;activemq:Invoicesquot;) .correlate(xpath(quot;/invoice/@purchaseOrderIdquot;).stringResult()); // now lets add some BAM rules invoice.starts().after(purchaseOrder.completes()) .expectWithin(seconds(1)) .errorIfOver(seconds(2)).to(quot;activemq:FailedProcessesquot;); } } 41