SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
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! :-)

Weitere ähnliche Inhalte

Was ist angesagt?

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
 
Unified Expression Language
Unified Expression LanguageUnified Expression Language
Unified Expression LanguageBG Java EE Course
 
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 Slides
Jsp SlidesJsp Slides
Jsp SlidesDSKUMAR G
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server PageVipin Yadav
 
JSP Error handling
JSP Error handlingJSP Error handling
JSP Error handlingkamal kotecha
 
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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 
Spring Capitulo 05
Spring Capitulo 05Spring Capitulo 05
Spring Capitulo 05Diego Pacheco
 
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
 
A First Date With Scala
A First Date With ScalaA First Date With Scala
A First Date With ScalaFranco Lombardo
 
Retrofitting
RetrofittingRetrofitting
RetrofittingTed Husted
 
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
 

Ähnlich wie 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
 

KĂźrzlich hochgeladen

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
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
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

KĂźrzlich hochgeladen (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech 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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

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! :-)