SlideShare a Scribd company logo
Taking
Apache Camel
 For A Ride
Bruce Snyder
bsnyder@apache.org
7 Nov 2008
New Orleans, Louisiana
Protocol Integration
    is Common
Data Format Integration
      is Common
Integration is Messy!
SOA = Spaghetti Oriented
      Architecture
Options For Integration
1             2




       3
Too Many Choices!
The Easiest Solution - Apache
           Camel




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




http://enterpriseintegrationpatterns.com/
Message Routing
Patterns
History of Apache Camel
Camel Components




http://activemq.apache.org/camel/components.html
Camel Components
Simple Routing
More Simple Routing
Pipeline Routing
Multicast Routing
Multicast-to-Many
 Pipeline Routes
Language Support
For Message Processing
 •   BeanShell    •   JSP EL
 •   Javascript   •   OGNL
 •   Groovy       •   SQL
 •   Python       •   XPath
 •   PHP          •   XQuery
 •   Ruby
Getting Started -
          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>
Pattern
Examples
Patterns
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;);
       }
  };
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>
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;);
  }
}
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>
Splitter




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;file://ordersquot;).
        splitter(body().tokenize(quot;nquot;)).
          to(quot;activemq:Order.Itemsquot;);
    }
  }
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;);
    }
  }
Aggregator



public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;activemq:Inventory.Itemsquot;).
      aggregator(header(quot;symbolquot;).isEqualTo(quot;IBMquot;).
        to(quot;activemq:Inventory.Orderquot;);
  }
}
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;);
    }
  }
Resequencer




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




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;direct:a”).routingSlip();
    }
  }
Throttler

public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;seda:a”).
        throttler(3).timePeriodMillis(30000).
          to(quot;seda:bquot;);
    }
  }
Delayer
public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;seda:a”).
        delayer(header(quot;JMSTimestampquot;, 3000).
          to(quot;seda:bquot;);
    }
  }
Load Balancer
    public class MyRouteBuilder extends RouteBuilder {
        public void configure() {
            from(quot;file:/path/to/filequot;).
            loadBalance().roundRobin().
                to(quot;seda:aquot;, quot;seda:bquot;, quot;seda:cquot;);
        }
   }



  Policy                                   Description
Round Robin    Balance the exchange load across the available endpoints

 Random        Randomly choose an endpoint to send the exchange

  Sticky       Sticky load balancing of exchanges using an expression

   Topic       Send exchange to all endpoints (like a JMS topic)
Multicast

public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;direct:aquot;).
      multicast().
      to(quot;direct:x?x=y&amp;1=2quot;, quot;direct:yquot;, quot;direct:zquot;);
    }
  }
Demo
More
Patterns
Wire Tap




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;direct:aquot;).
      to(quot;log:com.mycompany.messages?level=infoquot;).
      to(quot;mock:fooquot;);
    }
  }
Content Enricher




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;activemq:My.Queuequot;).
      to(quot;velocity:com/acme/MyResponse.vmquot;).
      to(quot;activemq:Another.Queuequot;);
    }
  }
More Content Enricher




public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;activemq:My.Queuequot;).
      beanRef(quot;myBeanNamequot;, quot;myMethodNamequot;).
      to(quot;activemq:Another.Queuequot;);
    }
  }
Content Filter




 public class MyRouteBuilder extends RouteBuilder {
      public void configure() {
        from(quot;direct:startquot;).process(new Processor() {
            public void process(Exchange exchange) {
                Message in = exchange.getIn();
                in.setBody(in.getBody(String.class) + quot; World!quot;);
            }
        }).to(quot;mock:resultquot;);
    }
}
Combine Patterns

public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;seda:a”).
        resequencer(header(quot;JMSGroupSeqquot;)).
        delayer(3000).
          to(quot;mock:xquot;);
    }
  }
Configure Error Handling

Global Error Handler:

RouteBuilder builder = new RouteBuilder() {
    public void configure() {
        errorHandler(deadLetterChannel(quot;file:errorsquot;));
        from(quot;bean:fooquot;).to(quot;seda:bquot;);
    }
};
Configure Error Handling


Local Error Handler:
RouteBuilder builder = new RouteBuilder() {
    public void configure() {
      from(quot;seda:aquot;).
        errorHandler(loggingErrorHandler(quot;FOO.BARquot;)).
        to(quot;seda:bquot;);

         from(quot;seda:bquot;).to(quot;seda:cquot;);
     }
};
Configure Exception Policies

RouteBuilder builder = new RouteBuilder() {
    public void configure() {
        exception(IOException.class)
          .initialRedeliveryDelay(5000L)
          .maximumRedeliveries(3)
          .maximumRedeliveryDelay(30000L)
          .backOffMultiplier(1.0)
          .useExponentialBackOff()
          .setHeader(MESSAGE_INFO, constant(quot;Damned IOException!quot;))
          .to(quot;activemq:errorsquot;);

         from(quot;seda:aquot;).to(quot;seda:bquot;);
     }
};
Beans
Make Context Discover Beans

  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>
Bean as a Message Translator

  public class MyRouteBuilder extends RouteBuilder {
      public void configure() {
        from(quot;activemq:Incoming”).
          beanRef(quot;myBeanquot;).
            to(quot;activemq:Outgoingquot;);
      }
    }
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;);
    }
}
Binding Beans to
     Camel Endpoints

public class Foo {

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

  public class Foo {

      public void onCheese(
        @XPath(quot;/foo/barquot;) String name,
        @Header(quot;JMSCorrelationIDquot;) String id) {
        ...
      }
  }
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;);
      }
    }
}
Type Conversion
Type Conversion

@Converter
public class IOConverter {

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

 public class MyRouteBuilder extends RouteBuilder {
      public void configure() {
        from(quot;direct:startquot;).process(new Processor() {
            public void process(Exchange exchange) {
                Message in = exchange.getIn();
                in.setBody(in.getBody(String.class) + quot; World!quot;);
            }
        }).to(quot;mock:resultquot;);
    }
}


             Support for the following types:
             • File
             • String
             • byte[] and ByteBuffer
             • InputStream and OutputStream
             • Reader and Writer
             • Document and Source
Message Mapper
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;);
    }
  }
Another
      Message Translator

public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
      from(quot;activemq:FOO.TEST”).
      transform(body().append(getDynamicText())).
        to(quot;http://outgoing.com/fooquot;);
  }
}
Business Activity Monitoring
          (BAM)
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;);
    }
}
Complex Routing is Easier
          from(“http://localhost:8080/requests/”).
              tryBlock().
                  to(“activemq:queue:requests”).
                  setOutBody(constant(“<ack/>”)).
              handle(Throwable.class).
                  setFaultBody(constant(“<nack/>”));

          from((“activemq:queue:requests?transacted=true”).
              process(requestTransformer).
              to(“http://host:8080/Request”).
              filter(xpath(“//nack”)).
              process(nackTransformer).
              to(“jdbc:store”);

          from(“http://localhost:8080/responses/”).
              tryBlock().
                  to(“activemq:queue:responses”).
                  setOutBody(constant(“<ack/>”)).
              handle(Throwable.class).
                  setFaultBody(constant(“<nack/>”));

          from(“activemq:queue:responses?transacted=true”).
              process(responseTransformer).
              to(“jdbc:store”);

          from(“http://localhost:8080/pull/”).
              to(“jdbc:load”);
Finally, the Camel Truck!
Ride the Camel!


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

More Related Content

What's hot

Map kit light
Map kit lightMap kit light
Map kit light
CocoaHeads France
 
RESTfull with RestKit
RESTfull with RestKitRESTfull with RestKit
RESTfull with RestKit
Taras Kalapun
 
Net/http and the http.handler interface
Net/http and the http.handler interfaceNet/http and the http.handler interface
Net/http and the http.handler interface
Joakim Gustin
 
From Node to Go
From Node to GoFrom Node to Go
From Node to Go
John Maxwell
 
Build Lightweight Web Module
Build Lightweight Web ModuleBuild Lightweight Web Module
Build Lightweight Web Module
Morgan Cheng
 
Win32 Perl Wmi
Win32 Perl WmiWin32 Perl Wmi
Win32 Perl Wmi
ddn123456
 
ReactiveCocoa in Practice
ReactiveCocoa in PracticeReactiveCocoa in Practice
ReactiveCocoa in Practice
Outware Mobile
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
Visual Engineering
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
AOE
 
Gmaps Railscamp2008
Gmaps Railscamp2008Gmaps Railscamp2008
Gmaps Railscamp2008
xilinus
 
Clojutre Real Life (2012 ClojuTRE Retro Edition)
Clojutre Real Life (2012 ClojuTRE Retro Edition)Clojutre Real Life (2012 ClojuTRE Retro Edition)
Clojutre Real Life (2012 ClojuTRE Retro Edition)
Metosin Oy
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented Networking
Mostafa Amer
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8
Hermann Hueck
 
Little Big Ruby
Little Big RubyLittle Big Ruby
Little Big Ruby
LittleBIGRuby
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript
jnewmanux
 
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Codemotion
 
Relaxing With CouchDB
Relaxing With CouchDBRelaxing With CouchDB
Relaxing With CouchDB
leinweber
 
Finch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with FinagleFinch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with Finagle
Vladimir Kostyukov
 
Utilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsUtilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and Operations
Neo4j
 

What's hot (19)

Map kit light
Map kit lightMap kit light
Map kit light
 
RESTfull with RestKit
RESTfull with RestKitRESTfull with RestKit
RESTfull with RestKit
 
Net/http and the http.handler interface
Net/http and the http.handler interfaceNet/http and the http.handler interface
Net/http and the http.handler interface
 
From Node to Go
From Node to GoFrom Node to Go
From Node to Go
 
Build Lightweight Web Module
Build Lightweight Web ModuleBuild Lightweight Web Module
Build Lightweight Web Module
 
Win32 Perl Wmi
Win32 Perl WmiWin32 Perl Wmi
Win32 Perl Wmi
 
ReactiveCocoa in Practice
ReactiveCocoa in PracticeReactiveCocoa in Practice
ReactiveCocoa in Practice
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
Gmaps Railscamp2008
Gmaps Railscamp2008Gmaps Railscamp2008
Gmaps Railscamp2008
 
Clojutre Real Life (2012 ClojuTRE Retro Edition)
Clojutre Real Life (2012 ClojuTRE Retro Edition)Clojutre Real Life (2012 ClojuTRE Retro Edition)
Clojutre Real Life (2012 ClojuTRE Retro Edition)
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented Networking
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8
 
Little Big Ruby
Little Big RubyLittle Big Ruby
Little Big Ruby
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript
 
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
 
Relaxing With CouchDB
Relaxing With CouchDBRelaxing With CouchDB
Relaxing With CouchDB
 
Finch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with FinagleFinch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with Finagle
 
Utilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsUtilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and Operations
 

Similar to Taking Apache Camel For A Ride

Riding Apache Camel
Riding Apache CamelRiding Apache Camel
Riding Apache Camel
Apache Event Beijing
 
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
Matthew McCullough
 
Aimaf
AimafAimaf
Aimaf
Saad RGUIG
 
Taking Apache Camel For a Ride
Taking Apache Camel For a RideTaking Apache Camel For a Ride
Taking Apache Camel For a Ride
Bruce Snyder
 
30 5 Database Jdbc
30 5 Database Jdbc30 5 Database Jdbc
30 5 Database Jdbc
phanleson
 
My java file
My java fileMy java file
My java file
Anamika Chauhan
 
Orbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyOrbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case Study
Mark Meeker
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
Hugo Hamon
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
Bruce Snyder
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
KAI CHU CHUNG
 
XML-Free Programming
XML-Free ProgrammingXML-Free Programming
XML-Free Programming
Stephen Chin
 
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
Bruce Snyder
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WS
Carol McDonald
 
Effecient javascript
Effecient javascriptEffecient javascript
Effecient javascript
mpnkhan
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
NAVER D2
 
Myfacesplanet
MyfacesplanetMyfacesplanet
Myfacesplanet
cagataycivici
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
LittleBIGRuby
 
Intro
IntroIntro
Intro
bspremo
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
Matt Raible
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
Dongmin Yu
 

Similar to Taking Apache Camel For A Ride (20)

Riding Apache Camel
Riding Apache CamelRiding Apache Camel
Riding Apache Camel
 
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
 
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
 
30 5 Database Jdbc
30 5 Database Jdbc30 5 Database Jdbc
30 5 Database Jdbc
 
My java file
My java fileMy java file
My java file
 
Orbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyOrbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case Study
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
 
XML-Free Programming
XML-Free ProgrammingXML-Free Programming
XML-Free Programming
 
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
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WS
 
Effecient javascript
Effecient javascriptEffecient javascript
Effecient javascript
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
Myfacesplanet
MyfacesplanetMyfacesplanet
Myfacesplanet
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
Intro
IntroIntro
Intro
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 

More from 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
 
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
 
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
 
EIP In Practice
EIP In PracticeEIP In Practice
EIP In Practice
Bruce Snyder
 
Messaging With ActiveMQ
Messaging With ActiveMQMessaging With ActiveMQ
Messaging With ActiveMQ
Bruce Snyder
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A Ride
Bruce Snyder
 

More from Bruce Snyder (12)

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
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With 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
 
EIP In Practice
EIP In PracticeEIP In Practice
EIP In Practice
 
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
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 

Taking Apache Camel For A Ride

  • 1. Taking Apache Camel For A Ride Bruce Snyder bsnyder@apache.org 7 Nov 2008 New Orleans, Louisiana
  • 5.
  • 6. SOA = Spaghetti Oriented Architecture
  • 7.
  • 10. The Easiest Solution - Apache Camel http://activemq.apache.org/camel/
  • 12. Enterprise Integration Patterns http://enterpriseintegrationpatterns.com/
  • 23. Language Support For Message Processing • BeanShell • JSP EL • Javascript • OGNL • Groovy • SQL • Python • XPath • PHP • XQuery • Ruby
  • 24. Getting Started - 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>
  • 27. 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;); } };
  • 28. 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>
  • 29. 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;); } }
  • 30. 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>
  • 31. Splitter public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;file://ordersquot;). splitter(body().tokenize(quot;nquot;)). to(quot;activemq:Order.Itemsquot;); } }
  • 32. 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;); } }
  • 33. Aggregator public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;activemq:Inventory.Itemsquot;). aggregator(header(quot;symbolquot;).isEqualTo(quot;IBMquot;). to(quot;activemq:Inventory.Orderquot;); } }
  • 34. 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;); } }
  • 35. Resequencer public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;direct:a”). resequencer(header(quot;customerRankquot;)). to(quot;seda:bquot;); } }
  • 36. Routing Slip public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;direct:a”).routingSlip(); } }
  • 37. Throttler public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;seda:a”). throttler(3).timePeriodMillis(30000). to(quot;seda:bquot;); } }
  • 38. Delayer public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;seda:a”). delayer(header(quot;JMSTimestampquot;, 3000). to(quot;seda:bquot;); } }
  • 39. Load Balancer public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;file:/path/to/filequot;). loadBalance().roundRobin(). to(quot;seda:aquot;, quot;seda:bquot;, quot;seda:cquot;); } } Policy Description Round Robin Balance the exchange load across the available endpoints Random Randomly choose an endpoint to send the exchange Sticky Sticky load balancing of exchanges using an expression Topic Send exchange to all endpoints (like a JMS topic)
  • 40. Multicast public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;direct:aquot;). multicast(). to(quot;direct:x?x=y&amp;1=2quot;, quot;direct:yquot;, quot;direct:zquot;); } }
  • 41. Demo
  • 43. Wire Tap public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;direct:aquot;). to(quot;log:com.mycompany.messages?level=infoquot;). to(quot;mock:fooquot;); } }
  • 44. Content Enricher public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;activemq:My.Queuequot;). to(quot;velocity:com/acme/MyResponse.vmquot;). to(quot;activemq:Another.Queuequot;); } }
  • 45. More Content Enricher public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;activemq:My.Queuequot;). beanRef(quot;myBeanNamequot;, quot;myMethodNamequot;). to(quot;activemq:Another.Queuequot;); } }
  • 46. Content Filter public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;direct:startquot;).process(new Processor() { public void process(Exchange exchange) { Message in = exchange.getIn(); in.setBody(in.getBody(String.class) + quot; World!quot;); } }).to(quot;mock:resultquot;); } }
  • 47. Combine Patterns public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;seda:a”). resequencer(header(quot;JMSGroupSeqquot;)). delayer(3000). to(quot;mock:xquot;); } }
  • 48. Configure Error Handling Global Error Handler: RouteBuilder builder = new RouteBuilder() { public void configure() { errorHandler(deadLetterChannel(quot;file:errorsquot;)); from(quot;bean:fooquot;).to(quot;seda:bquot;); } };
  • 49. Configure Error Handling Local Error Handler: RouteBuilder builder = new RouteBuilder() { public void configure() { from(quot;seda:aquot;). errorHandler(loggingErrorHandler(quot;FOO.BARquot;)). to(quot;seda:bquot;); from(quot;seda:bquot;).to(quot;seda:cquot;); } };
  • 50. Configure Exception Policies RouteBuilder builder = new RouteBuilder() { public void configure() { exception(IOException.class) .initialRedeliveryDelay(5000L) .maximumRedeliveries(3) .maximumRedeliveryDelay(30000L) .backOffMultiplier(1.0) .useExponentialBackOff() .setHeader(MESSAGE_INFO, constant(quot;Damned IOException!quot;)) .to(quot;activemq:errorsquot;); from(quot;seda:aquot;).to(quot;seda:bquot;); } };
  • 51. Beans
  • 52. Make Context Discover Beans 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>
  • 53. Bean as a Message Translator public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;activemq:Incoming”). beanRef(quot;myBeanquot;). to(quot;activemq:Outgoingquot;); } }
  • 54. 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;); } }
  • 55. Binding Beans to Camel Endpoints public class Foo { @MessageDriven(uri=quot;activemq:cheesequot;) public void onCheese(String name) { ... } }
  • 56. Binding Method Arguments public class Foo { public void onCheese( @XPath(quot;/foo/barquot;) String name, @Header(quot;JMSCorrelationIDquot;) String id) { ... } }
  • 57. 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;); } } }
  • 59. Type Conversion @Converter public class IOConverter { @Converter public static InputStream toInputStream(File file) throws FileNotFoundException { return new BufferedInputStream( new FileInputStream(file)); } }
  • 60. Type Convertors public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;direct:startquot;).process(new Processor() { public void process(Exchange exchange) { Message in = exchange.getIn(); in.setBody(in.getBody(String.class) + quot; World!quot;); } }).to(quot;mock:resultquot;); } } Support for the following types: • File • String • byte[] and ByteBuffer • InputStream and OutputStream • Reader and Writer • Document and Source
  • 62. 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;); } }
  • 63. Another Message Translator public class MyRouteBuilder extends RouteBuilder { public void configure() { from(quot;activemq:FOO.TEST”). transform(body().append(getDynamicText())). to(quot;http://outgoing.com/fooquot;); } }
  • 65. 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;); } }
  • 66. Complex Routing is Easier from(“http://localhost:8080/requests/”). tryBlock(). to(“activemq:queue:requests”). setOutBody(constant(“<ack/>”)). handle(Throwable.class). setFaultBody(constant(“<nack/>”)); from((“activemq:queue:requests?transacted=true”). process(requestTransformer). to(“http://host:8080/Request”). filter(xpath(“//nack”)). process(nackTransformer). to(“jdbc:store”); from(“http://localhost:8080/responses/”). tryBlock(). to(“activemq:queue:responses”). setOutBody(constant(“<ack/>”)). handle(Throwable.class). setFaultBody(constant(“<nack/>”)); from(“activemq:queue:responses?transacted=true”). process(responseTransformer). to(“jdbc:store”); from(“http://localhost:8080/pull/”). to(“jdbc:load”);
  • 68. Ride the Camel! http://activemq.apache.org/camel/