SlideShare a Scribd company logo
1 of 44
Download to read offline
Riding Apache Camel


        Willem Jiang
    ningjiang@apache.org
           2008-12
About author

• Apache CXF commiter and PMC member

• Apache Camel commiter and PMC member

• ningjiang@apache.org
Riding Apache Camel

•What's Camel

•EIP Examples

•Beans, Type Conversion , Data Format

•Some tips of Camel Riding
What is Camel?

        http://activemq.apache.org/camel/
What is Camel?

• A Camel can carry 4 times as much load as other beasts of burden!

• Apache Camel is a powerful Spring based Integration Framework.

• Camel implements the Enterprise Integration Patterns allowing you
  to configure routing and mediation rules in either a Java based
  Domain Specific Language (or Fluent API) or via Spring based Xml
  Configuration files. Either approaches mean you get smart completion
  of routing rules in your IDE whether in your Java or XML editor.

• Apache Camel uses URIs so that it can easily work directly with any
  kind of Transport or messaging model such as HTTP, ActiveMQ,
  JMS, JBI, MINA or CXF together with working with pluggable Data
  Format options. Apache Camel is a small library which has minimal
  dependencies for easy embedding in any Java application.
Book by Gregor & Bobby!
Message Routing
Message Routing in EIP
Camel Components
Simple Routing
More Simple Routing
Pipeline
Multicast Routing
Some examples of the EIP implemation
Message Filter
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>




from(quot;activemq:topic:Quotes).
  filter().xpath(quot;/quote/product = ‘widget’quot;).
    to(quot;mqseries:WidgetQuotesquot;);
Language Support For Message Processing

• BeanShell          • JSP EL

• Javascript         • OGNL

• Groovy             • SQL

• Python             • Xpath

• PHP                • XQuery

• Ruby
Message Filter : Spring XML


 <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
 <beans xmlns=quot;http://www.springframework.org/schema/beansquot;
        xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot;
        xmlns:schemaLocation=quot;http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://activemq.apache.org/camel/schema/spring
        http://activemq.apache.org/camel/schema/spring/camel-spring.xsdquot;>

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

 </beans>
Message Filter : Java Complete


package com.acme.quotes;

import org.apache.camel.builder.RouteBuilder;

public class MyRouteBuilder extends RouteBuilder {

     public void configure() {

         // forward widget quotes to MQSeries
         from(quot;activemq:topic:Quotes).
                 filter().xpath(quot;/quote/product = ‘widget’quot;).
                 to(quot;mqseries:WidgetQuotesquot;);
 }
}
Starting the CamelContext


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

  <camelContext id=quot;camelquot;
  xmlns=quot;http://activemq.apache.org/camel/schema/springquot;>
      <route>
        <from uri=quot;direct:startquot;/>
        <choice>
          <when>
            <xpath>$destination = 'firstChoice'</xpath>
            <to uri=quot;mock:matchedquot;/>
          </when>
          <otherwise>
            <to uri=quot;mock:notMatchedquot;/>
          </otherwise>
        </choice>
      </route>
    </camelContext>
Content Base Router




 from(quot;activemq:NewOrders”).
   choice().when(quot;/quote/product = ‘widget’quot;).
     to(quot;activemq:Orders.Widgetsquot;).
   choice().when(quot;/quote/product = ‘gadget’quot;).
     to(quot;activemq:Orders.Gadgetsquot;).
   otherwise().to(quot;activemq:Orders.Badquot;);
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>
How camel do this routing work ?
•Camel Components

 •Camel Endpoints

   •Camel Consumer

   •Camel Producer

•Camel-Core
How camel do this routing work ?




                 http://activemq.apache.org/camel/architecture.html
Beans
Bean as a Message Translator




from(quot;activemq:Incoming”).
  beanRef(quot;myBeanNamequot;).
    to(quot;activemq:Outgoingquot;);
Bean




public class Foo {

    public void someMethod(String name) {
      ...
    }
}
Bean as a Message Translator with method
name




from(quot;activemq:Incoming”).
  beanRef(quot;myBeanNamequot;, 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) {
        ...
      }
  }

for more annotations see
http://activemq.apache.org/camel/bean-integration.html
Type Conversion
Type Conversion

package com.acme.foo.converters;

import org.apache.camel.Converter;
import java.io.*;

@Converter
public class IOConverter {

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




    # META-INF/services/org/apache/camel/TypeConverter

    com.acme.foo.converters
Type Conversion

   protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {

from(quot;direct:startquot;).convertBodyTo(InputStream.class).to(quot;mock:resultquot;);
            }
        };
    }

    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
                   from(quot;direct:startquot;).process(new Processor() {
                public void process(Exchange exchange) {
                    Message in = exchange.getIn();
                    in.setBody(in.getBody(InputStream.class));

                 }
             }).to(quot;mock:resultquot;);
        };
    }
Data Format

from(quot;activemq:QueueWithJavaObjects).
  marshal().jaxb().
    to(quot;mqseries:QueueWithXmlMessagesquot;);

from(quot;activemq:QueueWithXmlMessages).
  unmarshal().jaxb().
    to(quot;mqseries:QueueWithJavaObjectsquot;);


from(quot;activemq:QueueTestMessage).
  marshal().zip().
to(quot;mqseries:QueueWithCompressMessagequot;);
Riding tips of camel
Camel Riding from Java




•/META-INF/spring/camelContext.xml

•set the CLASSPATH

•java org.apache.camel.spring.Main
Maven Tooling
<project>
...
    <build>
    <plugins>
       <plugin>
         <groupId>org.apache.camel</groupId>
         <artifactId>camel-maven-plugin</artifactId>
       </plugin>
     </plugins>
  </build>
  <reporting>
     <plugins>
       <plugin>
         <groupId>org.apache.camel</groupId>
         <artifactId>camel-maven-plugin</artifactId>
       </plugin>
     </plugins>
  </reporting>
</project>



mvn camel:run
Maven Plugin Site Report
Writing You Own Component

•Component

 •Endpoint

  •Consumer

  •Provider
Where would I use Camel?

•standalone or in any Spring application

•inside ActiveMQ’s JMS client or the
 broker

•inside your ESB such as ServiceMix via
 the servicemix-camel Service Unit

•inside CXF either as a transport or
 reusing CXF inside Camel
How to write your routing rule in Camel


•What's the magic of from, to, choice ......

 • /camel-core/src/main/java/org/apache/camel/model


•Implementing it in DSL way

 • Defining the type class that you want


•Implementing it in a Spring configuration way

 • Adding the annotation for JAXB consuming
Questions?
Let's take a look at Camel-CXF example
•Open eclipse and go to code please

•What does Camel-CXF example have ?

 •Multi-binding and Multi-transport supporting

 •LoadBalancing

 •JAXWS WebSerivce Provider API
Where do I get more info?
            please do take Camel for a ride!


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

                don’t get the hump! :-)

More Related Content

What's hot

JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesSiarhei Barysiuk
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC AnnotationsJordan Silva
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WSKatrien Verbert
 
Orbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyOrbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyMark Meeker
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIVisual Engineering
 
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.0Matt Raible
 
Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010arif44
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server PageVipin Yadav
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGESKalpana T
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questionsSujata Regoti
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsBG Java EE Course
 

What's hot (20)

JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WS
 
Lecture5
Lecture5Lecture5
Lecture5
 
Blood magic
Blood magicBlood magic
Blood magic
 
Orbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyOrbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case Study
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte III
 
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
 
Unified Expression Language
Unified Expression LanguageUnified Expression Language
Unified Expression Language
 
Data Access with JDBC
Data Access with JDBCData Access with JDBC
Data Access with JDBC
 
Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010
 
Jstl Guide
Jstl GuideJstl Guide
Jstl Guide
 
Jsp element
Jsp elementJsp element
Jsp element
 
Jsp Slides
Jsp SlidesJsp Slides
Jsp Slides
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
 
JSP Error handling
JSP Error handlingJSP Error handling
JSP Error handling
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGES
 
Rest with Spring
Rest with SpringRest with Spring
Rest with Spring
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questions
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 

Viewers also liked

Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache CamelFuseSource.com
 
Denis Sinyakov Photographer
Denis Sinyakov PhotographerDenis Sinyakov Photographer
Denis Sinyakov Photographerguimera
 
EBG "What's Hot?" (June 29, 2010)
EBG "What's Hot?" (June 29, 2010)EBG "What's Hot?" (June 29, 2010)
EBG "What's Hot?" (June 29, 2010)damoncb
 
Games Cl
Games ClGames Cl
Games Clgdyer
 
Ingles p.p yury
Ingles p.p yuryIngles p.p yury
Ingles p.p yurydanz-arte
 
Shannon and Karla - October 2010
Shannon and Karla - October 2010Shannon and Karla - October 2010
Shannon and Karla - October 2010guest7091e634
 
homecoming dress 2016
homecoming dress 2016homecoming dress 2016
homecoming dress 2016summer lu
 
18stka Karolinki :D
18stka Karolinki :D18stka Karolinki :D
18stka Karolinki :Dnatalus
 

Viewers also liked (9)

Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache Camel
 
Denis Sinyakov Photographer
Denis Sinyakov PhotographerDenis Sinyakov Photographer
Denis Sinyakov Photographer
 
EBG "What's Hot?" (June 29, 2010)
EBG "What's Hot?" (June 29, 2010)EBG "What's Hot?" (June 29, 2010)
EBG "What's Hot?" (June 29, 2010)
 
Games Cl
Games ClGames Cl
Games Cl
 
Ingles p.p yury
Ingles p.p yuryIngles p.p yury
Ingles p.p yury
 
Deutschland
DeutschlandDeutschland
Deutschland
 
Shannon and Karla - October 2010
Shannon and Karla - October 2010Shannon and Karla - October 2010
Shannon and Karla - October 2010
 
homecoming dress 2016
homecoming dress 2016homecoming dress 2016
homecoming dress 2016
 
18stka Karolinki :D
18stka Karolinki :D18stka Karolinki :D
18stka Karolinki :D
 

Similar to Ride Apache Camel: EIP Patterns, Components, Routing Rules

Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A RideBruce Snyder
 
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
 
Apache Camel - WJax 2008
Apache Camel - WJax 2008Apache Camel - WJax 2008
Apache Camel - WJax 2008inovex GmbH
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixBruce 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
 
Integration made easy with Apache Camel
Integration made easy with Apache CamelIntegration made easy with Apache Camel
Integration made easy with Apache CamelRosen Spasov
 
Xke - Introduction to Apache Camel
Xke - Introduction to Apache CamelXke - Introduction to Apache Camel
Xke - Introduction to Apache CamelAlexis Kinsella
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran TochAdil Jafri
 
Devclub Servicemix Jevgeni Holodkov 23 04 09
Devclub Servicemix Jevgeni Holodkov 23 04 09Devclub Servicemix Jevgeni Holodkov 23 04 09
Devclub Servicemix Jevgeni Holodkov 23 04 09helggeist
 
Developing Microservices with Apache Camel
Developing Microservices with Apache CamelDeveloping Microservices with Apache Camel
Developing Microservices with Apache CamelClaus Ibsen
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVCAlan Dean
 

Similar to Ride Apache Camel: EIP Patterns, Components, Routing Rules (20)

Taking Apache Camel For A Ride
Taking Apache Camel For A RideTaking Apache Camel For A Ride
Taking Apache Camel For A Ride
 
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMixEasy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
 
Apache Camel - WJax 2008
Apache Camel - WJax 2008Apache Camel - WJax 2008
Apache Camel - WJax 2008
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
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
 
Integration made easy with Apache Camel
Integration made easy with Apache CamelIntegration made easy with Apache Camel
Integration made easy with Apache Camel
 
Xke - Introduction to Apache Camel
Xke - Introduction to Apache CamelXke - Introduction to Apache Camel
Xke - Introduction to Apache Camel
 
Jsp
JspJsp
Jsp
 
Spring Capitulo 05
Spring Capitulo 05Spring Capitulo 05
Spring Capitulo 05
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
Combres
CombresCombres
Combres
 
Aimaf
AimafAimaf
Aimaf
 
My java file
My java fileMy java file
My java file
 
Ridingapachecamel
RidingapachecamelRidingapachecamel
Ridingapachecamel
 
Devclub Servicemix Jevgeni Holodkov 23 04 09
Devclub Servicemix Jevgeni Holodkov 23 04 09Devclub Servicemix Jevgeni Holodkov 23 04 09
Devclub Servicemix Jevgeni Holodkov 23 04 09
 
A First Date With Scala
A First Date With ScalaA First Date With Scala
A First Date With Scala
 
Retrofitting
RetrofittingRetrofitting
Retrofitting
 
Developing Microservices with Apache Camel
Developing Microservices with Apache CamelDeveloping Microservices with Apache Camel
Developing Microservices with Apache Camel
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Ride Apache Camel: EIP Patterns, Components, Routing Rules

  • 1. Riding Apache Camel Willem Jiang ningjiang@apache.org 2008-12
  • 2. About author • Apache CXF commiter and PMC member • Apache Camel commiter and PMC member • ningjiang@apache.org
  • 3. Riding Apache Camel •What's Camel •EIP Examples •Beans, Type Conversion , Data Format •Some tips of Camel Riding
  • 4. What is Camel? http://activemq.apache.org/camel/
  • 5. What is Camel? • A Camel can carry 4 times as much load as other beasts of burden! • Apache Camel is a powerful Spring based Integration Framework. • Camel implements the Enterprise Integration Patterns allowing you to configure routing and mediation rules in either a Java based Domain Specific Language (or Fluent API) or via Spring based Xml Configuration files. Either approaches mean you get smart completion of routing rules in your IDE whether in your Java or XML editor. • Apache Camel uses URIs so that it can easily work directly with any kind of Transport or messaging model such as HTTP, ActiveMQ, JMS, JBI, MINA or CXF together with working with pluggable Data Format options. Apache Camel is a small library which has minimal dependencies for easy embedding in any Java application.
  • 6. Book by Gregor & Bobby!
  • 14. Some examples of the EIP implemation
  • 16. 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> from(quot;activemq:topic:Quotes). filter().xpath(quot;/quote/product = ‘widget’quot;). to(quot;mqseries:WidgetQuotesquot;);
  • 17. Language Support For Message Processing • BeanShell • JSP EL • Javascript • OGNL • Groovy • SQL • Python • Xpath • PHP • XQuery • Ruby
  • 18. Message Filter : Spring XML <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <beans xmlns=quot;http://www.springframework.org/schema/beansquot; xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot; xmlns:schemaLocation=quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsdquot;> <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> </beans>
  • 19. Message Filter : Java Complete package com.acme.quotes; import org.apache.camel.builder.RouteBuilder; public class MyRouteBuilder extends RouteBuilder { public void configure() { // forward widget quotes to MQSeries from(quot;activemq:topic:Quotes). filter().xpath(quot;/quote/product = ‘widget’quot;). to(quot;mqseries:WidgetQuotesquot;); } }
  • 20. Starting the CamelContext CamelContext context = new DefaultCamelContext(); context.addRoutes(new MyRouteBuilder()); context.start(); <camelContext id=quot;camelquot; xmlns=quot;http://activemq.apache.org/camel/schema/springquot;> <route> <from uri=quot;direct:startquot;/> <choice> <when> <xpath>$destination = 'firstChoice'</xpath> <to uri=quot;mock:matchedquot;/> </when> <otherwise> <to uri=quot;mock:notMatchedquot;/> </otherwise> </choice> </route> </camelContext>
  • 21. Content Base Router from(quot;activemq:NewOrders”). choice().when(quot;/quote/product = ‘widget’quot;). to(quot;activemq:Orders.Widgetsquot;). choice().when(quot;/quote/product = ‘gadget’quot;). to(quot;activemq:Orders.Gadgetsquot;). otherwise().to(quot;activemq:Orders.Badquot;);
  • 22. 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>
  • 23. How camel do this routing work ? •Camel Components •Camel Endpoints •Camel Consumer •Camel Producer •Camel-Core
  • 24. How camel do this routing work ? http://activemq.apache.org/camel/architecture.html
  • 25. Beans
  • 26. Bean as a Message Translator from(quot;activemq:Incoming”). beanRef(quot;myBeanNamequot;). to(quot;activemq:Outgoingquot;);
  • 27. Bean public class Foo { public void someMethod(String name) { ... } }
  • 28. Bean as a Message Translator with method name from(quot;activemq:Incoming”). beanRef(quot;myBeanNamequot;, quot;someMethodquot;). to(quot;activemq:Outgoingquot;);
  • 29. Binding Beans to Camel Endpoints public class Foo { @MessageDriven(uri=quot;activemq:cheesequot;) public void onCheese(String name) { ... } }
  • 30. Binding Method Arguments public class Foo { public void onCheese( @XPath(quot;/foo/barquot;) String name, @Header(quot;JMSCorrelationIDquot;) String id) { ... } } for more annotations see http://activemq.apache.org/camel/bean-integration.html
  • 32. Type Conversion package com.acme.foo.converters; import org.apache.camel.Converter; import java.io.*; @Converter public class IOConverter { @Converter public static InputStream toInputStream(File file) throws FileNotFoundException { return new BufferedInputStream(new FileInputStream(file)); } } # META-INF/services/org/apache/camel/TypeConverter com.acme.foo.converters
  • 33. Type Conversion protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { from(quot;direct:startquot;).convertBodyTo(InputStream.class).to(quot;mock:resultquot;); } }; } protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { from(quot;direct:startquot;).process(new Processor() { public void process(Exchange exchange) { Message in = exchange.getIn(); in.setBody(in.getBody(InputStream.class)); } }).to(quot;mock:resultquot;); }; }
  • 34. Data Format from(quot;activemq:QueueWithJavaObjects). marshal().jaxb(). to(quot;mqseries:QueueWithXmlMessagesquot;); from(quot;activemq:QueueWithXmlMessages). unmarshal().jaxb(). to(quot;mqseries:QueueWithJavaObjectsquot;); from(quot;activemq:QueueTestMessage). marshal().zip(). to(quot;mqseries:QueueWithCompressMessagequot;);
  • 35. Riding tips of camel
  • 36. Camel Riding from Java •/META-INF/spring/camelContext.xml •set the CLASSPATH •java org.apache.camel.spring.Main
  • 37. Maven Tooling <project> ... <build> <plugins> <plugin> <groupId>org.apache.camel</groupId> <artifactId>camel-maven-plugin</artifactId> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.camel</groupId> <artifactId>camel-maven-plugin</artifactId> </plugin> </plugins> </reporting> </project> mvn camel:run
  • 39. Writing You Own Component •Component •Endpoint •Consumer •Provider
  • 40. Where would I use Camel? •standalone or in any Spring application •inside ActiveMQ’s JMS client or the broker •inside your ESB such as ServiceMix via the servicemix-camel Service Unit •inside CXF either as a transport or reusing CXF inside Camel
  • 41. How to write your routing rule in Camel •What's the magic of from, to, choice ...... • /camel-core/src/main/java/org/apache/camel/model •Implementing it in DSL way • Defining the type class that you want •Implementing it in a Spring configuration way • Adding the annotation for JAXB consuming
  • 43. Let's take a look at Camel-CXF example •Open eclipse and go to code please •What does Camel-CXF example have ? •Multi-binding and Multi-transport supporting •LoadBalancing •JAXWS WebSerivce Provider API
  • 44. Where do I get more info? please do take Camel for a ride! http://activemq.apache.org/camel/ don’t get the hump! :-)