SlideShare uma empresa Scribd logo
1 de 43
Baixar para ler 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="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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

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...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

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