SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Downloaden Sie, um offline zu lesen
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="http://activemq.apache.org/camel/schema/spring">
  <package>com.acme.quotes</package>
</camelContext>




                                                            13
Pattern
Examples
           14
Patterns Again




                 15
Content Based Router




  RouteBuilder builder = new RouteBuilder() {
 public void configure() {
   from("seda:a").choice().when(header("foo")
      .isEqualTo("bar")).to("seda:b")
        .when(header("foo").isEqualTo("cheese"))
          .to("seda:c").otherwise().to("seda:d");
        }
   };


                                                    16
Content Based Router

  <camelContext
    xmlns="http://activemq.apache.org/camel/schema/spring">
    <route>
      <from uri="activemq:NewOrders"/>
      <choice>
        <when>
          <xpath>/order/product = 'widget'</xpath>
          <to uri="activemq:Orders.Widgets"/>
        </when>
        <when>
          <xpath>/order/product = 'gadget'</xpath>
          <to uri="activemq:Orders.Gadgets"/>
        </when>
        <otherwise>
          <to uri="activemq:Orders.Bad"/>
        </otherwise>
      </choice>
    </route>
  </camelContext>



                                                              17
Message Filter




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




                                                           18
Message Filter

 <camelContext
   xmlns="http://activemq.apache.org/camel/schema/spring">
     <route>
       <from uri="activemq:topic:Quotes"/>
       <filter>
         <xpath>/quote/product = ‘widget’</xpath>
         <to uri="mqseries:WidgetQuotes"/>
       </filter>
     </route>
   </camelContext>




                                                             19
Splitter




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from("file://orders").
        splitter(body().tokenize("n")).
          to("activemq:Order.Items");
    }
  }


                                                     20
Splitter Using XQuery



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from("file://orders").
        splitter().xquery("/order/items").
          to("activemq:Order.Items");
    }
  }




                                                     21
Aggregator




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from("activemq:Inventory.Items").
        aggregator().xpath("/order/@id").
          to("activemq:Inventory.Order");
    }
  }




                                                     22
Message Translator




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




                                                     23
Resequencer




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from("direct:a”).
        resequencer(header("JMSPriority")).
          to("seda:b");
    }
  }



                                                     24
Throttler



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




                                                     25
Delayer



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from("seda:a”).
        delayer(header("JMSTimestamp", 3000).
          to("seda:b");
    }
  }




                                                     26
Combine Patterns



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from("seda:a”).
        resequencer(header("JMSPriority")).
        delayer(3000).
          to("seda:b");
    }
  }




                                                     27
Beans




        28
Bean


  package com.mycompany.beans;

  public class MyBean {

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



<camelContext
  xmlns="http://activemq.apache.org/camel/schema/spring">
  <package>com.mycompany.beans</package>
</camelContext>



                                                            29
Bean as a Message Translator



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from("activemq:Incoming”).
        beanRef("myBean").
          to("activemq:Outgoing");
    }
  }




                                                     30
Bean as a Message Translator


 *With Method Name


   public class MyRouteBuilder extends RouteBuilder {
       public void configure() {
           from("activemq:Incoming”).
             beanRef("myBean", "someMethod").
               to("activemq:Outgoing");
       }
   }




                                                        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="activemq:cheese")
    public void onCheese(String name) {
      ...
    }
}




                                            34
Binding Method Arguments

public class Foo {

    public void onCheese(
      @XPath("/foo/bar") String name,
      @Header("JMSCorrelationID") String id) {
      ...
    }
}




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


                                                                     35
Injecting Endpoints Into Beans


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

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




                                                        36
Spring Remoting - Server Side


 <camelContext
   xmlns="http://activemq.apache.org/camel/schema/spring">
   <export id="sayService"
     uri="activemq:MyService"
     serviceRef="sayImpl"
     serviceInterface="com.acme.MyServiceInterface"/>
 </camelContext>

 <bean id="sayImpl" class="com.acme.MyServiceImpl"/>




                                                             37
Spring Remoting - Client Side


 <camelContext
   xmlns="http://activemq.apache.org/camel/schema/spring">
   <proxy id="sayService" serviceUrl="activemq:MyService"
     serviceInterface="com.acme.MyServiceInterface"/>
 </camelContext>




                                                             38
Dependency Injection

<camelContext
  xmlns="http://activemq.apache.org/camel/schema/spring">
  ...
</camelContext>

<bean id="activemq"
  class="org.apache.camel.component.jms.JmsComponent">
  <property name="connectionFactory">
    <bean class="org.apache.activemq.ActiveMQConnectionFactory">
      <property name="brokerURL"
                value="vm://localhost?broker.persistent=false"/>
    </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("activemq:PurchaseOrders")
                .correlate(xpath("/purchaseOrder/@id").stringResult());

        ActivityBuilder invoice = activity("activemq:Invoices")
                .correlate(xpath("/invoice/@purchaseOrderId").stringResult());

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




                                                                                 41
Ride the Camel!




                  42
Questions?




             43

Weitere ähnliche Inhalte

Was ist angesagt?

td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shin
tutorialsruby
 
GR8Conf 2011: GORM Optimization
GR8Conf 2011: GORM OptimizationGR8Conf 2011: GORM Optimization
GR8Conf 2011: GORM Optimization
GR8Conf
 
April 2010 - JBoss Web Services
April 2010 - JBoss Web ServicesApril 2010 - JBoss Web Services
April 2010 - JBoss Web Services
JBug Italy
 

Was ist angesagt? (19)

HBase Client APIs (for webapps?)
HBase Client APIs (for webapps?)HBase Client APIs (for webapps?)
HBase Client APIs (for webapps?)
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 
G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVC
 
Rambler.iOS #6: App delegate - разделяй и властвуй
Rambler.iOS #6: App delegate - разделяй и властвуйRambler.iOS #6: App delegate - разделяй и властвуй
Rambler.iOS #6: App delegate - разделяй и властвуй
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A Ride
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
RicoLiveGrid
RicoLiveGridRicoLiveGrid
RicoLiveGrid
 
td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shin
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 
GR8Conf 2011: GORM Optimization
GR8Conf 2011: GORM OptimizationGR8Conf 2011: GORM Optimization
GR8Conf 2011: GORM Optimization
 
Optimize CollectionView Scrolling
Optimize CollectionView ScrollingOptimize CollectionView Scrolling
Optimize CollectionView Scrolling
 
11-DWR-and-JQuery
11-DWR-and-JQuery11-DWR-and-JQuery
11-DWR-and-JQuery
 
java
javajava
java
 
April 2010 - JBoss Web Services
April 2010 - JBoss Web ServicesApril 2010 - JBoss Web Services
April 2010 - JBoss Web Services
 
SpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSL
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Planet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance EnhancementPlanet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance Enhancement
 

Andere mochten auch

Workshop apache camel
Workshop apache camelWorkshop apache camel
Workshop apache camel
Marko Seifert
 
Self Repairing Tree Topology Enabling Content Based Routing In Local Area Ne...
Self Repairing Tree Topology Enabling  Content Based Routing In Local Area Ne...Self Repairing Tree Topology Enabling  Content Based Routing In Local Area Ne...
Self Repairing Tree Topology Enabling Content Based Routing In Local Area Ne...
ncct
 
Tml for Ruby on Rails
Tml for Ruby on RailsTml for Ruby on Rails
Tml for Ruby on Rails
Michael Berkovich
 

Andere mochten auch (20)

Workshop apache camel
Workshop apache camelWorkshop apache camel
Workshop apache camel
 
An introduction to Apache Camel
An introduction to Apache CamelAn introduction to Apache Camel
An introduction to Apache Camel
 
Xke - Introduction to Apache Camel
Xke - Introduction to Apache CamelXke - Introduction to Apache Camel
Xke - Introduction to Apache Camel
 
Cbr
CbrCbr
Cbr
 
Integration made easy with Apache Camel
Integration made easy with Apache CamelIntegration made easy with Apache Camel
Integration made easy with Apache Camel
 
Apache camel
Apache camelApache camel
Apache camel
 
«Spring Integration as Integration Patterns Provider»
«Spring Integration as Integration Patterns Provider»«Spring Integration as Integration Patterns Provider»
«Spring Integration as Integration Patterns Provider»
 
Apache Camel Lifecycle
Apache Camel LifecycleApache Camel Lifecycle
Apache Camel Lifecycle
 
Apache Camel & The Art of Entreprise Integration
Apache Camel & The Art of Entreprise IntegrationApache Camel & The Art of Entreprise Integration
Apache Camel & The Art of Entreprise Integration
 
Wild Flies and a Camel Java EE Integration Stories
Wild Flies and a Camel Java EE Integration StoriesWild Flies and a Camel Java EE Integration Stories
Wild Flies and a Camel Java EE Integration Stories
 
Apache Camel
Apache CamelApache Camel
Apache Camel
 
Self Repairing Tree Topology Enabling Content Based Routing In Local Area Ne...
Self Repairing Tree Topology Enabling  Content Based Routing In Local Area Ne...Self Repairing Tree Topology Enabling  Content Based Routing In Local Area Ne...
Self Repairing Tree Topology Enabling Content Based Routing In Local Area Ne...
 
Messaging with Spring Integration
Messaging with Spring IntegrationMessaging with Spring Integration
Messaging with Spring Integration
 
Spring Integration and EIP Introduction
Spring Integration and EIP IntroductionSpring Integration and EIP Introduction
Spring Integration and EIP Introduction
 
Elegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache CamelElegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache Camel
 
Consuming External Content and Enriching Content with Apache Camel
Consuming External Content and Enriching Content with Apache CamelConsuming External Content and Enriching Content with Apache Camel
Consuming External Content and Enriching Content with Apache Camel
 
Event Driven Architecture with Apache Camel
Event Driven Architecture with Apache CamelEvent Driven Architecture with Apache Camel
Event Driven Architecture with Apache Camel
 
Tml for Ruby on Rails
Tml for Ruby on RailsTml for Ruby on Rails
Tml for Ruby on Rails
 
Apache Camel - The integration library
Apache Camel - The integration libraryApache Camel - The integration library
Apache Camel - The integration library
 
Integration Patterns With Spring integration
Integration Patterns With Spring integrationIntegration Patterns With Spring integration
Integration Patterns With Spring integration
 

Ähnlich wie Taking Apache Camel For a Ride

Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMixEasy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
elliando dias
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
Bruce Snyder
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
Luke Summerfield
 
Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8
Ovadiah Myrgorod
 
Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015
Tobias Mattsson
 

Ähnlich wie Taking Apache Camel For a Ride (20)

DOSUG Taking Apache Camel For A Ride
DOSUG Taking Apache Camel For A RideDOSUG Taking Apache Camel For A Ride
DOSUG Taking Apache Camel For A Ride
 
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMixEasy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
 
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
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
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
 
Riding Apache Camel
Riding Apache CamelRiding Apache Camel
Riding Apache Camel
 
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
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworks
 
Fun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksFun Teaching MongoDB New Tricks
Fun Teaching MongoDB New Tricks
 
Camel one v3-6
Camel one v3-6Camel one v3-6
Camel one v3-6
 
Testing microservices: Tools and Frameworks
Testing microservices: Tools and FrameworksTesting microservices: Tools and Frameworks
Testing microservices: Tools and Frameworks
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8
 
Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015
 
Backbone js-slides
Backbone js-slidesBackbone js-slides
Backbone js-slides
 

Mehr von Bruce Snyder

Beyond Horizontal Scalability: Concurrency and Messaging Using Spring
Beyond Horizontal Scalability: Concurrency and Messaging Using SpringBeyond Horizontal Scalability: Concurrency and Messaging Using Spring
Beyond Horizontal Scalability: Concurrency and Messaging Using Spring
Bruce Snyder
 
Enterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMSEnterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMS
Bruce Snyder
 
Styles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using SpringStyles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using Spring
Bruce Snyder
 
ActiveMQ In Action
ActiveMQ In ActionActiveMQ In Action
ActiveMQ In Action
Bruce Snyder
 
ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011
Bruce Snyder
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMix
Bruce Snyder
 
Messaging With Apache ActiveMQ
Messaging With Apache ActiveMQMessaging With Apache ActiveMQ
Messaging With Apache ActiveMQ
Bruce Snyder
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMS
Bruce Snyder
 

Mehr von Bruce Snyder (11)

Beyond Horizontal Scalability: Concurrency and Messaging Using Spring
Beyond Horizontal Scalability: Concurrency and Messaging Using SpringBeyond Horizontal Scalability: Concurrency and Messaging Using Spring
Beyond Horizontal Scalability: Concurrency and Messaging Using Spring
 
Enterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMSEnterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMS
 
Styles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using SpringStyles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using Spring
 
ActiveMQ In Action
ActiveMQ In ActionActiveMQ In Action
ActiveMQ In Action
 
ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMix
 
Messaging With Apache ActiveMQ
Messaging With Apache ActiveMQMessaging With Apache ActiveMQ
Messaging With Apache ActiveMQ
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMS
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
Messaging With ActiveMQ
Messaging With ActiveMQMessaging With ActiveMQ
Messaging With ActiveMQ
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A Ride
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

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="http://activemq.apache.org/camel/schema/spring"> <package>com.acme.quotes</package> </camelContext> 13
  • 16. Content Based Router RouteBuilder builder = new RouteBuilder() { public void configure() { from("seda:a").choice().when(header("foo") .isEqualTo("bar")).to("seda:b") .when(header("foo").isEqualTo("cheese")) .to("seda:c").otherwise().to("seda:d"); } }; 16
  • 17. Content Based Router <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="activemq:NewOrders"/> <choice> <when> <xpath>/order/product = 'widget'</xpath> <to uri="activemq:Orders.Widgets"/> </when> <when> <xpath>/order/product = 'gadget'</xpath> <to uri="activemq:Orders.Gadgets"/> </when> <otherwise> <to uri="activemq:Orders.Bad"/> </otherwise> </choice> </route> </camelContext> 17
  • 18. Message Filter public class MyRouteBuilder extends RouteBuilder { public void configure() { from("activemq:topic:Quotes). filter().xpath("/quote/product = ‘widget’"). to("mqseries:WidgetQuotes"); } } 18
  • 19. Message Filter <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="activemq:topic:Quotes"/> <filter> <xpath>/quote/product = ‘widget’</xpath> <to uri="mqseries:WidgetQuotes"/> </filter> </route> </camelContext> 19
  • 20. Splitter public class MyRouteBuilder extends RouteBuilder { public void configure() { from("file://orders"). splitter(body().tokenize("n")). to("activemq:Order.Items"); } } 20
  • 21. Splitter Using XQuery public class MyRouteBuilder extends RouteBuilder { public void configure() { from("file://orders"). splitter().xquery("/order/items"). to("activemq:Order.Items"); } } 21
  • 22. Aggregator public class MyRouteBuilder extends RouteBuilder { public void configure() { from("activemq:Inventory.Items"). aggregator().xpath("/order/@id"). to("activemq:Inventory.Order"); } } 22
  • 23. Message Translator public class MyRouteBuilder extends RouteBuilder { public void configure() { from("file://incoming”). to("xslt:com/acme/mytransform.xsl"). to("http://outgoing.com/foo"); } } 23
  • 24. Resequencer public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:a”). resequencer(header("JMSPriority")). to("seda:b"); } } 24
  • 25. Throttler public class MyRouteBuilder extends RouteBuilder { public void configure() { from("seda:a”). throttler(3).timePeriodMillis(30000). to("seda:b"); } } 25
  • 26. Delayer public class MyRouteBuilder extends RouteBuilder { public void configure() { from("seda:a”). delayer(header("JMSTimestamp", 3000). to("seda:b"); } } 26
  • 27. Combine Patterns public class MyRouteBuilder extends RouteBuilder { public void configure() { from("seda:a”). resequencer(header("JMSPriority")). delayer(3000). to("seda:b"); } } 27
  • 28. Beans 28
  • 29. Bean package com.mycompany.beans; public class MyBean { public void someMethod(String name) { ... } } <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <package>com.mycompany.beans</package> </camelContext> 29
  • 30. Bean as a Message Translator public class MyRouteBuilder extends RouteBuilder { public void configure() { from("activemq:Incoming”). beanRef("myBean"). to("activemq:Outgoing"); } } 30
  • 31. Bean as a Message Translator *With Method Name public class MyRouteBuilder extends RouteBuilder { public void configure() { from("activemq:Incoming”). beanRef("myBean", "someMethod"). to("activemq:Outgoing"); } } 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="activemq:cheese") public void onCheese(String name) { ... } } 34
  • 35. Binding Method Arguments public class Foo { public void onCheese( @XPath("/foo/bar") String name, @Header("JMSCorrelationID") String id) { ... } } http://activemq.apache.org/camel/bean-integration.html 35
  • 36. Injecting Endpoints Into Beans public class Foo { @EndpointInject(uri="activemq:foo.bar") ProducerTemplate producer; public void doSomething() { if (whatever) { producer.sendBody("<hello>world!</hello>"); } } } 36
  • 37. Spring Remoting - Server Side <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <export id="sayService" uri="activemq:MyService" serviceRef="sayImpl" serviceInterface="com.acme.MyServiceInterface"/> </camelContext> <bean id="sayImpl" class="com.acme.MyServiceImpl"/> 37
  • 38. Spring Remoting - Client Side <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <proxy id="sayService" serviceUrl="activemq:MyService" serviceInterface="com.acme.MyServiceInterface"/> </camelContext> 38
  • 39. Dependency Injection <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> ... </camelContext> <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent"> <property name="connectionFactory"> <bean class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="vm://localhost?broker.persistent=false"/> </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("activemq:PurchaseOrders") .correlate(xpath("/purchaseOrder/@id").stringResult()); ActivityBuilder invoice = activity("activemq:Invoices") .correlate(xpath("/invoice/@purchaseOrderId").stringResult()); // now lets add some BAM rules invoice.starts().after(purchaseOrder.completes()) .expectWithin(seconds(1)) .errorIfOver(seconds(2)).to("activemq:FailedProcesses"); } } 41