SlideShare uma empresa Scribd logo
1 de 54
Baixar para ler offline
Using
Enterprise Integration Patterns
    as Your Camel Jockey


            Bruce Snyder
         bsnyder@apache.org

            IASA Denver
           September 2009     1
Integration
     is
everywhere!
          2
Just Because You Can, Doesn’t Mean You Should




                                           3
And Then There’s the Llama Car




                                 4
Options For Integration


1                             2




               3




                                  5
Option One - DIY




              Do It Yourself
                               6
Option Two - Buy It




                      Buy It
                               7
Option Three - Adopt It




                  Adopt It
                             8
What Are Design Patterns?




       A design pattern is a formal way of
       documenting a solution to a design
       problem in a particular field of
       expertise.
     (Wikipedia)




                                             9
Enterprise Integration Patterns




Got EIP?
Pattern Overview




                   11
Visualizing EIPs




:: Stencils exist for Visio and OmniGraffle
   :: http://www.eaipatterns.com/downloads.html




                                                  12
What is Apache Camel?




                           A framework for simplifying
                           integration through the use of the
                           Enterprise Integration Patterns for
                           message mediation, processing,
http://camel.apache.org/
                           routing and transformation




                                                             13
Apache Camel is Focused on EIP




                            =>




 http://camel.apache.org/        http://eaipatterns.com/

                                                           14
History of Apache Camel




                          15
Message Routing




        from("A").to("B");




                             16
Simple Routing




        from("file:///tmp/myFile.txt").
        to("jms:TEST.Q");




                                          17
Slightly More Complex Routing




    from("file:///tmp/myFile.txt").
    to("bean:MyBean?method=handleMessage").
    to("jms:TEST.Q");




                                              18
Multicast Routing




     from("file:///tmp/myFile.txt").
     choice().when().
       method("MyBean", "matches").
       to("Q").
     end().
     multicast("B", "C", "D");
                                       19
Pipeline Routing




     from("file:///tmp/myFile.txt").
     choice().when().
       method("MyBean", "matches").
       to("Q").
     end().
     pipeline("B", "C", "D");

                                       20
Camel Components

:: 70+ components supported




                              21
Pattern
Examples
           22
Patterns Again




                 23
Content Based Router




   RouteBuilder builder = new RouteBuilder() {
    public void configure() {
     from("activemq:NewOrders")
       .choice()
         .when(header("order-type").isEqualTo("widget"))
           .to("activemq:Orders.Widgets")
         .when(header("order-type").isEqualTo("gadget"))
           .to("activemq:Orders.Gadgets")
         .otherwise()
           .to("file:errors");
         }
     };                                                    Java DSL
                                                                24
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>
                                                            Spring DSL
                                                                   25
Message Filter




     public class MyRouteBuilder extends RouteBuilder {
        public void configure() {
          from("activemq:topic:Orders)
             .filter().xpath("/order/product = ʻwidgetʼ")
                .to("ftp://bsnyder@host:2223/widgets/orders");
      }
     }




                                                                 Java DSL
                                                                      26
Message Filter



    <camelContext
     xmlns="http://activemq.apache.org/camel/schema/spring">
      <route>
       <from uri="activemq:topic:Orders"/>
       <filter>
         <xpath>/order/product = ʻwidgetʼ</xpath>
         <to uri="ftp://bsnyder@host:2223/widgets/orders"/>
       </filter>
      </route>
     </camelContext>




                                                               Spring DSL
                                                                      27
Splitter




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


                                                            Java DSL
                                                                 28
Splitter




          <camelContext id="camel"
      xmlns="http://camel.apache.org/schema/spring">
      <route>
       <from uri="file:///orders" />
       <split>
         <tokenize token="n" />
         <to uri="activemq:Order.Items" />
       </split>
      </route>
     </camelContext>




                                                       Spring DSL
                                                              29
Aggregator




    public class MyRouteBuilder extends RouteBuilder {
      public void configure() {
        from("activemq:STOCKS")
        .aggregator(header("symbol"))
          .batchSize(10)
          .to("activemq:MY.STOCKS");
      }
    }


                                                         Java DSL
                                                              30
Aggregator




         <camelContext id="camel"
     xmlns="http://camel.apache.org/schema/spring">
     <route>
      <from uri="file:///orders" />
      <aggregate>
        <correlationExpression>
         <simple>header.symbol</simple>
        </correlationExpression>
        <batchSize>10</batchSize>
        <to uri="activemq:MY.STOCKS" />
       </aggregate>
     </route>
    </camelContext>



                                                      Spring DSL
                                                             31
Throttler



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




                                                           Java DSL
                                                                32
Delayer



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




                                                         Java DSL
                                                              33
Load Balancer

   public class MyRouteBuilder extends RouteBuilder {
      public void configure() {
        from("file:/path/to/file")
        .loadBalance().roundRobin()
           .to("file:///one", "activemq:MY.Q", "http://host1:8181/fooApp");
     }
  }



   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 (JMS topic semantics)

                                                                             Java DSL
                                                                                  34
Multicast


    public class MyRouteBuilder extends RouteBuilder {
      public void configure() {
        from("direct:a")
          .multicast()
          .to("direct:x", "mock:y", "file:///tmp/bar?fileName=test.txt");
        }
      }




                                                                          Java DSL
                                                                               35
More
Patterns
           36
Wire Tap




      public class MyRouteBuilder extends RouteBuilder {
        public void configure() {
          from("direct:a")
            .to("log:com.mycompany.messages?level=info")
            .to("mock:foo");
          }
        }



                                                           Java DSL
                                                                37
Content Enricher




      public class MyRouteBuilder extends RouteBuilder {
        public void configure() {
          from("activemq:My.Queue")
            .to("velocity:com/acme/MyResponse.vm")
            .to("activemq:Another.Queue");
          }
        }



                                                           Java DSL
                                                                38
More Content Enricher




     public class MyRouteBuilder extends RouteBuilder {
         public void configure() {
          from("activemq:My.Queue")
            .beanRef("myPojo", “methodName”)
            .to("activemq:Another.Queue");
       }
     }



                                                          Java DSL
                                                               39
Content Filter




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



                                                                   Java DSL
                                                                        40
Combine Patterns



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




                                                           Java DSL
                                                                41
Error Handling in Camel

:: Global Error Handler:
        RouteBuilder builder = new RouteBuilder() {
            public void configure() {
                errorHandler(deadLetterChannel("file:errors"));
                from("bean:foo").to("seda:b");
          }
        };



:: Local Error Handler:
        RouteBuilder builder = new RouteBuilder() {
            public void configure() {
              from("seda:a").
                errorHandler(loggingErrorHandler("FOO.BAR")).
                to("seda:b");
              from("seda:b").to("seda:c");
          }                                                      Java DSL
        };                                                            42
Exception Policies in Camel


 RouteBuilder builder = new RouteBuilder() {
     public void configure() {
         exception(IOException.class)
           .initialRedeliveryDelay(5000L)
           .maximumRedeliveries(3)
           .maximumRedeliveryDelay(30000L)
           .backOffMultiplier(1.0)
           .useExponentialBackOff()
           .setHeader(MESSAGE_INFO, constant("Damned IOException!"))
           .to("activemq:errors");
         from("seda:a").to("seda:b");
    }
 }; 




                                                                       Java DSL
                                                                            43
Make Context Discover Beans



          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>




                                                                44
Bean as a Message Translator



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




                                                           Java DSL
                                                                45
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");
          }
      }




                                                           Java DSL
                                                                46
Binding Beans to Camel Endpoints


        public class Foo {

            @MessageDriven(uri=”activemq:cheese”)
            public void onCheese(String name) {
              ...
            }
        }




                                                    Java DSL
                                                         47
Binding Method Arguments


        public class Foo {

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




                                                         Java DSL
                                                              48
Injecting Endpoints Into Beans


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

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




                                                             Java DSL
                                                                  49
Type Convertors

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



       Support for the following types:
       • File
       • String
       • byte[] and ByteBuffer
       • InputStream and OutputStream
       • Reader and Writer
       • Document and Source
                                                                  50
Type Conversion


       @Converter
       public class IOConverter {

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




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


                                                                                52
The Camel Truck!




                   53
Ride the
Camel!
http://camel.apache.org/

       bsnyder@apache.org
   http://twitter.com/brucesnyder   54

Mais conteúdo relacionado

Mais procurados

Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzJBug Italy
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentationsourabh aggarwal
 
April 2010 - JBoss Web Services
April 2010 - JBoss Web ServicesApril 2010 - JBoss Web Services
April 2010 - JBoss Web ServicesJBug Italy
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RSFahad Golra
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBossJBug Italy
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with SpringJoshua Long
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWeare-Legion
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVCDzmitry Naskou
 
Petro Gordiievych "From Java 9 to Java 12"
Petro Gordiievych "From Java 9 to Java 12"Petro Gordiievych "From Java 9 to Java 12"
Petro Gordiievych "From Java 9 to Java 12"LogeekNightUkraine
 
Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望 Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望 javatwo2011
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsGuy Nir
 
MWLUG 2015 - AD114 Take Your XPages Development to the Next Level
MWLUG 2015 - AD114 Take Your XPages Development to the Next LevelMWLUG 2015 - AD114 Take Your XPages Development to the Next Level
MWLUG 2015 - AD114 Take Your XPages Development to the Next Levelbalassaitis
 
SpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSunghyouk Bae
 
When Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of TorqueboxWhen Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of Torqueboxrockyjaiswal
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 

Mais procurados (19)

JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter PilgrimJavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzz
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentation
 
April 2010 - JBoss Web Services
April 2010 - JBoss Web ServicesApril 2010 - JBoss Web Services
April 2010 - JBoss Web Services
 
Java 9
Java 9Java 9
Java 9
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBoss
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 
Petro Gordiievych "From Java 9 to Java 12"
Petro Gordiievych "From Java 9 to Java 12"Petro Gordiievych "From Java 9 to Java 12"
Petro Gordiievych "From Java 9 to Java 12"
 
11-DWR-and-JQuery
11-DWR-and-JQuery11-DWR-and-JQuery
11-DWR-and-JQuery
 
Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望 Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
MWLUG 2015 - AD114 Take Your XPages Development to the Next Level
MWLUG 2015 - AD114 Take Your XPages Development to the Next LevelMWLUG 2015 - AD114 Take Your XPages Development to the Next Level
MWLUG 2015 - AD114 Take Your XPages Development to the Next Level
 
SpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSL
 
When Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of TorqueboxWhen Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of Torquebox
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 

Semelhante a Using Enterprise Integration Patterns as Your Camel Jockey

Taking Apache Camel For a Ride
Taking Apache Camel For a RideTaking Apache Camel For a Ride
Taking Apache Camel For a RideBruce Snyder
 
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 RideMatthew McCullough
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsJudy Breedlove
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSuzquiano
 
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 ServiceMixelliando dias
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixBruce Snyder
 
TS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in PracticeTS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in Practiceaegloff
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A RideBruce Snyder
 
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code ExampleMaven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code ExampleNikhil Bhalwankar
 
Developing a new Scala DSL for Apache Camel
Developing a new Scala DSL for Apache CamelDeveloping a new Scala DSL for Apache Camel
Developing a new Scala DSL for Apache Camelelliando dias
 
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 8Ovadiah Myrgorod
 
Introduction To Apache Mesos
Introduction To Apache MesosIntroduction To Apache Mesos
Introduction To Apache MesosJoe Stein
 
JavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and FutureJavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and FutureIgalia
 

Semelhante a Using Enterprise Integration Patterns as Your Camel Jockey (20)

Taking Apache Camel For a Ride
Taking Apache Camel For a RideTaking Apache Camel For a Ride
Taking Apache Camel For a Ride
 
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
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
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
 
Camel as a_glue
Camel as a_glueCamel as a_glue
Camel as a_glue
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
 
TS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in PracticeTS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in Practice
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A Ride
 
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code ExampleMaven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
Maven + Jsf + Richfaces + Jxl + Jdbc - Complete Code Example
 
Camel Scala
Camel ScalaCamel Scala
Camel Scala
 
camel-scala.pdf
camel-scala.pdfcamel-scala.pdf
camel-scala.pdf
 
Developing a new Scala DSL for Apache Camel
Developing a new Scala DSL for Apache CamelDeveloping a new Scala DSL for Apache Camel
Developing a new Scala DSL for Apache Camel
 
camel-scala.pdf
camel-scala.pdfcamel-scala.pdf
camel-scala.pdf
 
camel-scala.pdf
camel-scala.pdfcamel-scala.pdf
camel-scala.pdf
 
camel-scala.pdf
camel-scala.pdfcamel-scala.pdf
camel-scala.pdf
 
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
 
Introduction To Apache Mesos
Introduction To Apache MesosIntroduction To Apache Mesos
Introduction To Apache Mesos
 
JavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and FutureJavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and Future
 

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 SpringBruce Snyder
 
Enterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMSEnterprise Messaging With Spring JMS
Enterprise Messaging With Spring JMSBruce Snyder
 
Styles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using SpringStyles of Applicaton Integration Using Spring
Styles of Applicaton Integration Using SpringBruce Snyder
 
ActiveMQ In Action
ActiveMQ In ActionActiveMQ In Action
ActiveMQ In ActionBruce Snyder
 
ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011Bruce Snyder
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixBruce Snyder
 
Messaging With Apache ActiveMQ
Messaging With Apache ActiveMQMessaging With Apache ActiveMQ
Messaging With Apache ActiveMQBruce 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 JMSBruce Snyder
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixBruce Snyder
 
Messaging With ActiveMQ
Messaging With ActiveMQMessaging With ActiveMQ
Messaging With ActiveMQBruce Snyder
 
Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A RideBruce Snyder
 

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

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Último (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Using Enterprise Integration Patterns as Your Camel Jockey

  • 1. Using Enterprise Integration Patterns as Your Camel Jockey Bruce Snyder bsnyder@apache.org IASA Denver September 2009 1
  • 2. Integration is everywhere! 2
  • 3. Just Because You Can, Doesn’t Mean You Should 3
  • 4. And Then There’s the Llama Car 4
  • 6. Option One - DIY Do It Yourself 6
  • 7. Option Two - Buy It Buy It 7
  • 8. Option Three - Adopt It Adopt It 8
  • 9. What Are Design Patterns? A design pattern is a formal way of documenting a solution to a design problem in a particular field of expertise. (Wikipedia) 9
  • 12. Visualizing EIPs :: Stencils exist for Visio and OmniGraffle :: http://www.eaipatterns.com/downloads.html 12
  • 13. What is Apache Camel? A framework for simplifying integration through the use of the Enterprise Integration Patterns for message mediation, processing, http://camel.apache.org/ routing and transformation 13
  • 14. Apache Camel is Focused on EIP => http://camel.apache.org/ http://eaipatterns.com/ 14
  • 15. History of Apache Camel 15
  • 16. Message Routing from("A").to("B"); 16
  • 17. Simple Routing from("file:///tmp/myFile.txt"). to("jms:TEST.Q"); 17
  • 18. Slightly More Complex Routing from("file:///tmp/myFile.txt"). to("bean:MyBean?method=handleMessage"). to("jms:TEST.Q"); 18
  • 19. Multicast Routing from("file:///tmp/myFile.txt"). choice().when(). method("MyBean", "matches"). to("Q"). end(). multicast("B", "C", "D"); 19
  • 20. Pipeline Routing from("file:///tmp/myFile.txt"). choice().when(). method("MyBean", "matches"). to("Q"). end(). pipeline("B", "C", "D"); 20
  • 21. Camel Components :: 70+ components supported 21
  • 24. Content Based Router RouteBuilder builder = new RouteBuilder() { public void configure() { from("activemq:NewOrders") .choice() .when(header("order-type").isEqualTo("widget")) .to("activemq:Orders.Widgets") .when(header("order-type").isEqualTo("gadget")) .to("activemq:Orders.Gadgets") .otherwise() .to("file:errors"); } }; Java DSL 24
  • 25. 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> Spring DSL 25
  • 26. Message Filter public class MyRouteBuilder extends RouteBuilder { public void configure() { from("activemq:topic:Orders) .filter().xpath("/order/product = ʻwidgetʼ") .to("ftp://bsnyder@host:2223/widgets/orders"); } } Java DSL 26
  • 27. Message Filter <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="activemq:topic:Orders"/> <filter> <xpath>/order/product = ʻwidgetʼ</xpath> <to uri="ftp://bsnyder@host:2223/widgets/orders"/> </filter> </route> </camelContext> Spring DSL 27
  • 28. Splitter public class MyRouteBuilder extends RouteBuilder { public void configure() { from("file:///orders") .splitter(body(String.class).tokenize("n")) .to("activemq:Order.Items"); } } Java DSL 28
  • 29. Splitter <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="file:///orders" /> <split> <tokenize token="n" /> <to uri="activemq:Order.Items" /> </split> </route> </camelContext> Spring DSL 29
  • 30. Aggregator public class MyRouteBuilder extends RouteBuilder { public void configure() { from("activemq:STOCKS") .aggregator(header("symbol")) .batchSize(10) .to("activemq:MY.STOCKS"); } } Java DSL 30
  • 31. Aggregator <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="file:///orders" /> <aggregate> <correlationExpression> <simple>header.symbol</simple> </correlationExpression> <batchSize>10</batchSize> <to uri="activemq:MY.STOCKS" /> </aggregate> </route> </camelContext> Spring DSL 31
  • 32. Throttler public class MyRouteBuilder extends RouteBuilder { public void configure() { from("seda:a”) .throttler(3).timePeriodMillis(30000) .to("seda:b"); } } Java DSL 32
  • 33. Delayer public class MyRouteBuilder extends RouteBuilder { public void configure() { from("seda:a”) .delayer(header("JMSTimestamp", 3000) .to("seda:b"); } } Java DSL 33
  • 34. Load Balancer public class MyRouteBuilder extends RouteBuilder { public void configure() { from("file:/path/to/file") .loadBalance().roundRobin() .to("file:///one", "activemq:MY.Q", "http://host1:8181/fooApp"); } } 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 (JMS topic semantics) Java DSL 34
  • 35. Multicast public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:a") .multicast() .to("direct:x", "mock:y", "file:///tmp/bar?fileName=test.txt"); } } Java DSL 35
  • 37. Wire Tap public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:a") .to("log:com.mycompany.messages?level=info") .to("mock:foo"); } } Java DSL 37
  • 38. Content Enricher public class MyRouteBuilder extends RouteBuilder { public void configure() { from("activemq:My.Queue") .to("velocity:com/acme/MyResponse.vm") .to("activemq:Another.Queue"); } } Java DSL 38
  • 39. More Content Enricher public class MyRouteBuilder extends RouteBuilder { public void configure() { from("activemq:My.Queue") .beanRef("myPojo", “methodName”) .to("activemq:Another.Queue"); } } Java DSL 39
  • 40. Content Filter public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:start").process(new Processor() { public void process(Exchange exchange) { Message in = exchange.getIn(); in.setBody(in.getBody(String.class) + " World!"); } }).to("mock:result"); } } Java DSL 40
  • 41. Combine Patterns public class MyRouteBuilder extends RouteBuilder { public void configure() { from("seda:a”). resequencer(header("JMSGroupSeq")). delayer(3000). to("mock:x"); } } Java DSL 41
  • 42. Error Handling in Camel :: Global Error Handler: RouteBuilder builder = new RouteBuilder() {     public void configure() {         errorHandler(deadLetterChannel("file:errors"));         from("bean:foo").to("seda:b");   } }; :: Local Error Handler: RouteBuilder builder = new RouteBuilder() {     public void configure() {       from("seda:a").         errorHandler(loggingErrorHandler("FOO.BAR")).         to("seda:b");       from("seda:b").to("seda:c");   } Java DSL }; 42
  • 43. Exception Policies in Camel RouteBuilder builder = new RouteBuilder() {     public void configure() {         exception(IOException.class)           .initialRedeliveryDelay(5000L)           .maximumRedeliveries(3)           .maximumRedeliveryDelay(30000L)           .backOffMultiplier(1.0)           .useExponentialBackOff()           .setHeader(MESSAGE_INFO, constant("Damned IOException!"))           .to("activemq:errors");         from("seda:a").to("seda:b");    } };  Java DSL 43
  • 44. Make Context Discover Beans 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> 44
  • 45. Bean as a Message Translator public class MyRouteBuilder extends RouteBuilder { public void configure() { from("activemq:Incoming”). beanRef("myBean"). to("activemq:Outgoing"); } } Java DSL 45
  • 46. 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"); } } Java DSL 46
  • 47. Binding Beans to Camel Endpoints public class Foo { @MessageDriven(uri=”activemq:cheese”) public void onCheese(String name) { ... } } Java DSL 47
  • 48. Binding Method Arguments public class Foo { public void onCheese( @XPath(“/foo/bar/”) String name, @Header(“JMSCorrelationID”) String id) { ... } } Java DSL 48
  • 49. Injecting Endpoints Into Beans public class Foo { @EndpointInject(uri= “activemq:foo.bar”) ProducerTemplate producer; public void doSomething() { if (whatever) { producer.sendBody(“<hello>world</hello>”); } } } Java DSL 49
  • 50. Type Convertors public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:start").process(new Processor() { public void process(Exchange exchange) { Message in = exchange.getIn(); in.setBody(in.getBody(String.class) + " World!"); } }).to("mock:result"); } } Support for the following types: • File • String • byte[] and ByteBuffer • InputStream and OutputStream • Reader and Writer • Document and Source 50
  • 51. Type Conversion @Converter public class IOConverter { @Converter public static InputStream toInputStream(File file) throws FileNotFoundException { return new BufferedInputStream( new FileInputStream(file)); } } 51
  • 52. 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"); } } 52
  • 54. Ride the Camel! http://camel.apache.org/ bsnyder@apache.org http://twitter.com/brucesnyder 54