SlideShare una empresa de Scribd logo
1 de 38
Descargar para leer sin conexión
Aimaf
Aimaf
Application:
     B



                BPM




                BAM




 Application:
      A
Aimaf
é




                   Apache ServiceMix : Bus d’intégration (Flux,
     FUSE ESB	     processus techniques) basé sur JBI et OSGI	


  FUSE Message     Apache ActiveMQ : Courtier de messagerie (MOM) basé
     Broker	       sur JMS	



       FUSE         Apache CXF : permet de créer ou consommer des
     Services       Services Web	
    Framework 	


FUSE Mediation 
   Apache Camel : moteur de routage permettant de
    Router	        créer des patterns d'intégration avec une formation
                   minimale grâce à un langage Java simple ou avec XML
Aimaf
Aimaf
Aimaf
Aimaf
Aimaf
Aimaf
#
# Framework selection properties
#
karaf.framework=equinox

#
# Location of the OSGi frameworks
#
karaf.framework.equinox=${karaf.default.repository}/org/eclipse/osgi/....
karaf.framework.felix=${karaf.default.repository}/org/apache/felix/.....
Aimaf
<groupId>fr.aimaf</groupId>
	   <artifactId>Example</artifactId>
	   <packaging>bundle</packaging>
	   <version>0.1</version>
	   <name>Aimaf Example :: Camel OSGi Bundle</name>
Aimaf
Expéditeur:                   Destinataire
Application                   Application
     A                             B




              Queue
                  Queue
                      Queue
Aimaf
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
      xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
      xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
      xmlns:amq="http://activemq.apache.org/schema/core">
  <!-- Allows us to use system properties as variables in this configuration file -->
  <ext:property-placeholder />
  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="default" dataDirectory="${karaf.data}/activemq/default" useShutdownHook="false">
    <destinationPolicy>
       <policyMap>
        <policyEntries>
          <policyEntry topic=">" producerFlowControl="true" memoryLimit="1mb">
           <pendingSubscriberPolicy>
            <vmCursor />
           </pendingSubscriberPolicy>
          </policyEntry>
          <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb">
          </policyEntry>
        </policyEntries>
       </policyMap>
    </destinationPolicy>
    <!-- Use the following to configure how ActiveMQ is exposed in JMX -->
    <managementContext>
       <managementContext createConnector="false"/>
    </managementContext>
    <persistenceAdapter>
       <kahaDB directory="${karaf.data}/activemq/default/kahadb"/>
    </persistenceAdapter>
    <!-- The transport connectors ActiveMQ will listen to -->
    <transportConnectors>
       <transportConnector name="openwire" uri="tcp://localhost:61616"/>
       <transportConnector name="stomp" uri="stomp://localhost:61613"/>
    </transportConnectors>
  </broker>

  <bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">

    <property name="brokerURL" value="tcp://localhost:61616" />
  </bean>

  <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
    <property name="maxConnections" value="8" />
    <property name="connectionFactory" ref="activemqConnectionFactory" />
  </bean>

  <bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager" init-method="recoverResource">
     <property name="transactionManager" ref="transactionManager" />
     <property name="connectionFactory" ref="activemqConnectionFactory" />
     <property name="resourceName" value="activemq.default" />
  </bean>

  <reference id="transactionManager" interface="javax.transaction.TransactionManager" />
  <service ref="pooledConnectionFactory" interface="javax.jms.ConnectionFactory">
    <service-properties>
       <entry key="name" value="localhost"/>
    </service-properties>
  </service>
</blueprint>
Aimaf
Aimaf
Aimaf
Aimaf
class MyRouteBuilder extends RouteBuilder {
	     "direct:a" --> "mock:a"
	   }
                                              public class MyRouteBuilder extends RouteBuilder {
                                              	   @Override
                                              	   public void configure() throws Exception {
                                              	   	   from("direct:a")
                                              	   	   .to("mock:a");

                                              	   }
                                              }




<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="direct:a"/>
    <to uri="mock:a"/>
  </route>
</camelContext>
public class MyRouteBuilder extends RouteBuilder {

                public void configure() {
                	 Processor myProcessor = new MyProcessor();
           	   	 from("URI1")
           	   	 	 .process(myProcessor)
           	   	 	 	 ...
                             .to("URI2");
                }
           }



public class MyProcessor implements Processor{

	   public void process(Exchange exchange) throws Exception {
	   	 //Use exchange methods for processing it ...
	   }
}
Aimaf
log.info("Source : "+exchange.getFromEndpoint());
	   	   log.info("Pattern : "+exchange.getPattern());
	   	   log.info("Exchange ID : "+exchange.getExchangeId());

	   	   log.info("---------- Here Starts Headers ----------");
	   	   Map<String,Object> dictionnaire = exchange.getIn().getHeaders();
	   	   for (final String cle : dictionnaire.keySet()) {
	   	   	 log.info("Key : "+cle+" Value : "+dictionnaire.get(cle));
	   	   }
	   	
	   	   log.info("---------- Here Starts Properties -------");
	   	   Map<String,Object> dictionnaire2 = exchange.getProperties();
	   	   for (final String cle : dictionnaire2.keySet()) {
	   	   	 log.info("Key : "+cle+" Value : "+dictionnaire2.get(cle));
	   	   }
INFO   Source : Endpoint[file://src/data/?fileName=livraison.csv&noop=true]
INFO   Pattern : InOnly
INFO   Exchange ID : ID-saad-local-51012-1303566625671-0-2
INFO   ---------- Here Starts Headers ----------
INFO   Key : camelfilenameonly Value : livraison.csv
INFO   Key : camelfileparent Value : src/data
INFO   Key : camelfilename Value : livraison.csv
INFO   Key : camelfileabsolute Value : false
INFO   Key : camelfilelength Value : 115
INFO   Key : camelfilerelativepath Value : livraison.csv
INFO   Key : camelfilepath Value : src/data/livraison.csv
INFO   Key : camelfilelastmodified Value : Sat Apr 16 08:26:18 CEST 2011
INFO   Key : camelfileabsolutepath Value : /users/saadrguig/Desktop/CAMEL-CSV-TEST/src/data/livraison.csv
INFO   ---------- Here Starts Properties -------
INFO   Key : CamelBatchComplete Value : true
INFO   Key : CamelBatchSize Value : 1
INFO   Key : CamelCreatedTimestamp Value : Sat Apr 23 15:50:27 CEST 2011
INFO   Key : CamelFileExchangeFile Value : GenericFile[livraison.csv]
INFO   Key : Propriete 1 Value : Contenu de La propriete 1
INFO   Key : CamelBatchIndex Value : 0
<dependency>
	   	 <groupId>org.apache.camel</groupId>
	   	 <artifactId>camel-test</artifactId>
	   	 <version>${camel-version}</version>
	   </dependency>
	   <dependency>	
       <groupId>junit</groupId>
	   	 <artifactId>junit</artifactId>
	   	 <version>${junit-version}</version>
	   </dependency>
Aimaf
public class MyClassTest extends CamelTestSupport{
	   @Test
	   public void methodeTest() throws Exception{
	
	   	   CamelContext context = new DefaultCamelContext();
	   	   context.addRoutes(creaeRoutes());
	   	   context.start();
	   	   MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
	   	   mock.expectedBodiesReceived("What ever you expect !");

	   	     ProducerTemplate template = context.createProducerTemplate();
	   	     template.sendBody("direct:MyEndpoint1", MyMessage);
	   	     mock.assertIsSatisfied();
	   }
private    RouteBuilder creaeRoutes() {
	   	     return new RouteBuilder(){
	   	     	   @Override
	   	     	   public void configure() throws Exception {
	   	     	   	    from("direct:MyEndpoint1")
                    	 ....<routing + transformations...>
                    	 	   .to("mock:result");
	   	     	   }
	   	     };
from("file:src/data?noop=true")
    .choice()
	   	    .when(header("CamelFileName").endsWith(".xml"))
	   	    	   .to("seda:xmlLivraison")
	   	    .when(header("CamelFileName").regex("^.*(csv|csl)$"))
	   	    	   .to("seda:csvLivraison");

from("seda:csvLivraison")
	   .split(body(String.class).tokenize("n"))
    	
    	    .unmarshal(camelDataFormat)
        		   .bean(Controler.class)
        		   	    .wireTap("direct:tap")
        		   	    	   .multicast()
        		   	    	   	    .to("jms:queue:livraison?jmsMessageType=Text")
        		   	    	   	    .to("log:Mail----------------------->?level=INFO");

from("direct:tap")
	   .process(myTransformer)
	   	    .marshal(jaxb)
	   	    	   .choice()
	   	    	   	     .when(xpath("/livraison/mode = 'chronopost'"))
	   	    	   	     	 .to("direct:multicast")
	   	    	   	     .otherwise()
	   	    	   	     	 .multicast()
	   	    	   	     	 	     .to("file:target/out/colissimo")
	   	    	   	     	 	     .to("log:JAXB----------------------->?level=INFO");

from("direct:multicast")
	   .multicast()
	   	    .parallelProcessing()
	   	    	   .multicast().to("file:target/out/chronopost",
	   	    	   	    	   	   	    "smtps://smtp.gmail.com?username=srguig&password="+password+From+Subject);
[1) thread #1 - seda://csvOrder] Mail----------------------->   INFO Exchange[ExchangePattern:InOnly, BodyType:java.util.ArrayList, Body:
[{fr.aimaf.model.csv.LivraisonCSV=LivraisonCSV [ref_transaction=981928.0, nom_client=nom_client, prenom_client=prenom_client,
telephone=telephone, email=email, addresse1=addresse1, addresse2=addresse2, code_postal=code_postal, ville=Paris, nomArticle=nomArticle,
mode_livraison=chronopost, relais=relais, date_cmd=Mon Apr 25 00:00:00 CEST 2011, poids_colis=10.0, port_paye=5.0]}]]
[ (camel-1) thread #2 - WireTap] Transformer                    INFO ------------> Processor: Ville de LivraisonCSV------------> Paris
....
Aimaf
Aimaf
Aimaf
Aimaf
Aimaf
Aimaf

Más contenido relacionado

La actualidad más candente

Mastering Spring Boot's Actuator with Madhura Bhave
Mastering Spring Boot's Actuator with Madhura BhaveMastering Spring Boot's Actuator with Madhura Bhave
Mastering Spring Boot's Actuator with Madhura BhaveVMware Tanzu
 
Naked Performance With Clojure
Naked Performance With ClojureNaked Performance With Clojure
Naked Performance With ClojureMetosin Oy
 
Re-Design with Elixir/OTP
Re-Design with Elixir/OTPRe-Design with Elixir/OTP
Re-Design with Elixir/OTPMustafa TURAN
 
Writing Redis in Python with asyncio
Writing Redis in Python with asyncioWriting Redis in Python with asyncio
Writing Redis in Python with asyncioJames Saryerwinnie
 
Designing with malli
Designing with malliDesigning with malli
Designing with malliMetosin Oy
 
Malli: inside data-driven schemas
Malli: inside data-driven schemasMalli: inside data-driven schemas
Malli: inside data-driven schemasMetosin Oy
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天tblanlan
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-futureyiming he
 
Common mistakes functional java | Oracle Code One 2018
Common mistakes functional java | Oracle Code One 2018Common mistakes functional java | Oracle Code One 2018
Common mistakes functional java | Oracle Code One 2018Brian Vermeer
 
Common mistakes functional java vjug
Common mistakes functional java vjugCommon mistakes functional java vjug
Common mistakes functional java vjugBrian Vermeer
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...Codemotion
 
Ten common mistakes made with Functional Java JBCNConf18
Ten common mistakes made with Functional Java JBCNConf18Ten common mistakes made with Functional Java JBCNConf18
Ten common mistakes made with Functional Java JBCNConf18Brian Vermeer
 
Api Design
Api DesignApi Design
Api Designsartak
 
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
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswanivvaswani
 
Filling the flask
Filling the flaskFilling the flask
Filling the flaskJason Myers
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuningAOE
 

La actualidad más candente (20)

Mastering Spring Boot's Actuator with Madhura Bhave
Mastering Spring Boot's Actuator with Madhura BhaveMastering Spring Boot's Actuator with Madhura Bhave
Mastering Spring Boot's Actuator with Madhura Bhave
 
Naked Performance With Clojure
Naked Performance With ClojureNaked Performance With Clojure
Naked Performance With Clojure
 
Re-Design with Elixir/OTP
Re-Design with Elixir/OTPRe-Design with Elixir/OTP
Re-Design with Elixir/OTP
 
Writing Redis in Python with asyncio
Writing Redis in Python with asyncioWriting Redis in Python with asyncio
Writing Redis in Python with asyncio
 
Designing with malli
Designing with malliDesigning with malli
Designing with malli
 
Malli: inside data-driven schemas
Malli: inside data-driven schemasMalli: inside data-driven schemas
Malli: inside data-driven schemas
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
 
Common mistakes functional java | Oracle Code One 2018
Common mistakes functional java | Oracle Code One 2018Common mistakes functional java | Oracle Code One 2018
Common mistakes functional java | Oracle Code One 2018
 
Common mistakes functional java vjug
Common mistakes functional java vjugCommon mistakes functional java vjug
Common mistakes functional java vjug
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...
 
Ten common mistakes made with Functional Java JBCNConf18
Ten common mistakes made with Functional Java JBCNConf18Ten common mistakes made with Functional Java JBCNConf18
Ten common mistakes made with Functional Java JBCNConf18
 
Api Design
Api DesignApi Design
Api Design
 
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
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
Filling the flask
Filling the flaskFilling the flask
Filling the flask
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
OneRing @ OSCamp 2010
OneRing @ OSCamp 2010OneRing @ OSCamp 2010
OneRing @ OSCamp 2010
 

Destacado (10)

Formation aimaf-android-part1
Formation aimaf-android-part1Formation aimaf-android-part1
Formation aimaf-android-part1
 
ActiveBAM
ActiveBAMActiveBAM
ActiveBAM
 
Sydney Mobile - April 2010 - WP7
Sydney Mobile - April 2010 - WP7Sydney Mobile - April 2010 - WP7
Sydney Mobile - April 2010 - WP7
 
Presentación1
Presentación1Presentación1
Presentación1
 
C:\Fakepath\Tance Y Mato
C:\Fakepath\Tance Y MatoC:\Fakepath\Tance Y Mato
C:\Fakepath\Tance Y Mato
 
Formation aimaf-android-part2
Formation aimaf-android-part2Formation aimaf-android-part2
Formation aimaf-android-part2
 
Bpe Survey Presentation
Bpe Survey PresentationBpe Survey Presentation
Bpe Survey Presentation
 
Anegats presetacio
Anegats presetacioAnegats presetacio
Anegats presetacio
 
Gaz
GazGaz
Gaz
 
ActionBar Android
ActionBar AndroidActionBar Android
ActionBar Android
 

Similar a Aimaf

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
 
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
 
Using Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel JockeyUsing Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel JockeyBruce Snyder
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixBruce Snyder
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsFrancois Zaninotto
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomyDongmin Yu
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 
Introduction To Apache Mesos
Introduction To Apache MesosIntroduction To Apache Mesos
Introduction To Apache MesosJoe Stein
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache MesosJoe Stein
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortalJennifer Bourey
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSuzquiano
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsJudy Breedlove
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5Martin Kleppe
 
Reitit - Clojure/North 2019
Reitit - Clojure/North 2019Reitit - Clojure/North 2019
Reitit - Clojure/North 2019Metosin Oy
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Hugo Hamon
 

Similar a Aimaf (20)

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
 
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
 
Using Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel JockeyUsing Enterprise Integration Patterns as Your Camel Jockey
Using Enterprise Integration Patterns as Your Camel Jockey
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
Camel as a_glue
Camel as a_glueCamel as a_glue
Camel as a_glue
 
Introduction To Apache Mesos
Introduction To Apache MesosIntroduction To Apache Mesos
Introduction To Apache Mesos
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
Riding Apache Camel
Riding Apache CamelRiding Apache Camel
Riding Apache Camel
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
 
Server Side Swift: Vapor
Server Side Swift: VaporServer Side Swift: Vapor
Server Side Swift: Vapor
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
 
Reitit - Clojure/North 2019
Reitit - Clojure/North 2019Reitit - Clojure/North 2019
Reitit - Clojure/North 2019
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 

Aimaf

  • 3. Application: B BPM BAM Application: A
  • 5. é Apache ServiceMix : Bus d’intégration (Flux, FUSE ESB processus techniques) basé sur JBI et OSGI FUSE Message Apache ActiveMQ : Courtier de messagerie (MOM) basé Broker sur JMS FUSE Apache CXF : permet de créer ou consommer des Services Services Web Framework FUSE Mediation 
 Apache Camel : moteur de routage permettant de Router créer des patterns d'intégration avec une formation minimale grâce à un langage Java simple ou avec XML
  • 12. # # Framework selection properties # karaf.framework=equinox # # Location of the OSGi frameworks # karaf.framework.equinox=${karaf.default.repository}/org/eclipse/osgi/.... karaf.framework.felix=${karaf.default.repository}/org/apache/felix/.....
  • 14. <groupId>fr.aimaf</groupId> <artifactId>Example</artifactId> <packaging>bundle</packaging> <version>0.1</version> <name>Aimaf Example :: Camel OSGi Bundle</name>
  • 16. Expéditeur: Destinataire Application Application A B Queue Queue Queue
  • 18. <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0" xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0" xmlns:amq="http://activemq.apache.org/schema/core"> <!-- Allows us to use system properties as variables in this configuration file --> <ext:property-placeholder /> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="default" dataDirectory="${karaf.data}/activemq/default" useShutdownHook="false"> <destinationPolicy> <policyMap> <policyEntries> <policyEntry topic=">" producerFlowControl="true" memoryLimit="1mb"> <pendingSubscriberPolicy> <vmCursor /> </pendingSubscriberPolicy> </policyEntry> <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb"> </policyEntry> </policyEntries> </policyMap> </destinationPolicy> <!-- Use the following to configure how ActiveMQ is exposed in JMX --> <managementContext> <managementContext createConnector="false"/> </managementContext> <persistenceAdapter> <kahaDB directory="${karaf.data}/activemq/default/kahadb"/> </persistenceAdapter> <!-- The transport connectors ActiveMQ will listen to --> <transportConnectors> <transportConnector name="openwire" uri="tcp://localhost:61616"/> <transportConnector name="stomp" uri="stomp://localhost:61613"/> </transportConnectors> </broker> <bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="tcp://localhost:61616" /> </bean> <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"> <property name="maxConnections" value="8" /> <property name="connectionFactory" ref="activemqConnectionFactory" /> </bean> <bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager" init-method="recoverResource"> <property name="transactionManager" ref="transactionManager" /> <property name="connectionFactory" ref="activemqConnectionFactory" /> <property name="resourceName" value="activemq.default" /> </bean> <reference id="transactionManager" interface="javax.transaction.TransactionManager" /> <service ref="pooledConnectionFactory" interface="javax.jms.ConnectionFactory"> <service-properties> <entry key="name" value="localhost"/> </service-properties> </service> </blueprint>
  • 23. class MyRouteBuilder extends RouteBuilder { "direct:a" --> "mock:a" } public class MyRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from("direct:a") .to("mock:a"); } } <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:a"/> <to uri="mock:a"/> </route> </camelContext>
  • 24. public class MyRouteBuilder extends RouteBuilder { public void configure() { Processor myProcessor = new MyProcessor(); from("URI1") .process(myProcessor) ... .to("URI2"); } } public class MyProcessor implements Processor{ public void process(Exchange exchange) throws Exception { //Use exchange methods for processing it ... } }
  • 26. log.info("Source : "+exchange.getFromEndpoint()); log.info("Pattern : "+exchange.getPattern()); log.info("Exchange ID : "+exchange.getExchangeId()); log.info("---------- Here Starts Headers ----------"); Map<String,Object> dictionnaire = exchange.getIn().getHeaders(); for (final String cle : dictionnaire.keySet()) { log.info("Key : "+cle+" Value : "+dictionnaire.get(cle)); } log.info("---------- Here Starts Properties -------"); Map<String,Object> dictionnaire2 = exchange.getProperties(); for (final String cle : dictionnaire2.keySet()) { log.info("Key : "+cle+" Value : "+dictionnaire2.get(cle)); }
  • 27. INFO Source : Endpoint[file://src/data/?fileName=livraison.csv&noop=true] INFO Pattern : InOnly INFO Exchange ID : ID-saad-local-51012-1303566625671-0-2 INFO ---------- Here Starts Headers ---------- INFO Key : camelfilenameonly Value : livraison.csv INFO Key : camelfileparent Value : src/data INFO Key : camelfilename Value : livraison.csv INFO Key : camelfileabsolute Value : false INFO Key : camelfilelength Value : 115 INFO Key : camelfilerelativepath Value : livraison.csv INFO Key : camelfilepath Value : src/data/livraison.csv INFO Key : camelfilelastmodified Value : Sat Apr 16 08:26:18 CEST 2011 INFO Key : camelfileabsolutepath Value : /users/saadrguig/Desktop/CAMEL-CSV-TEST/src/data/livraison.csv INFO ---------- Here Starts Properties ------- INFO Key : CamelBatchComplete Value : true INFO Key : CamelBatchSize Value : 1 INFO Key : CamelCreatedTimestamp Value : Sat Apr 23 15:50:27 CEST 2011 INFO Key : CamelFileExchangeFile Value : GenericFile[livraison.csv] INFO Key : Propriete 1 Value : Contenu de La propriete 1 INFO Key : CamelBatchIndex Value : 0
  • 28. <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-test</artifactId> <version>${camel-version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit-version}</version> </dependency>
  • 30. public class MyClassTest extends CamelTestSupport{ @Test public void methodeTest() throws Exception{ CamelContext context = new DefaultCamelContext(); context.addRoutes(creaeRoutes()); context.start(); MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class); mock.expectedBodiesReceived("What ever you expect !"); ProducerTemplate template = context.createProducerTemplate(); template.sendBody("direct:MyEndpoint1", MyMessage); mock.assertIsSatisfied(); } private RouteBuilder creaeRoutes() { return new RouteBuilder(){ @Override public void configure() throws Exception { from("direct:MyEndpoint1") ....<routing + transformations...> .to("mock:result"); } };
  • 31. from("file:src/data?noop=true") .choice() .when(header("CamelFileName").endsWith(".xml")) .to("seda:xmlLivraison") .when(header("CamelFileName").regex("^.*(csv|csl)$")) .to("seda:csvLivraison"); from("seda:csvLivraison") .split(body(String.class).tokenize("n")) .unmarshal(camelDataFormat) .bean(Controler.class) .wireTap("direct:tap") .multicast() .to("jms:queue:livraison?jmsMessageType=Text") .to("log:Mail----------------------->?level=INFO"); from("direct:tap") .process(myTransformer) .marshal(jaxb) .choice() .when(xpath("/livraison/mode = 'chronopost'")) .to("direct:multicast") .otherwise() .multicast() .to("file:target/out/colissimo") .to("log:JAXB----------------------->?level=INFO"); from("direct:multicast") .multicast() .parallelProcessing() .multicast().to("file:target/out/chronopost", "smtps://smtp.gmail.com?username=srguig&password="+password+From+Subject);
  • 32. [1) thread #1 - seda://csvOrder] Mail-----------------------> INFO Exchange[ExchangePattern:InOnly, BodyType:java.util.ArrayList, Body: [{fr.aimaf.model.csv.LivraisonCSV=LivraisonCSV [ref_transaction=981928.0, nom_client=nom_client, prenom_client=prenom_client, telephone=telephone, email=email, addresse1=addresse1, addresse2=addresse2, code_postal=code_postal, ville=Paris, nomArticle=nomArticle, mode_livraison=chronopost, relais=relais, date_cmd=Mon Apr 25 00:00:00 CEST 2011, poids_colis=10.0, port_paye=5.0]}]] [ (camel-1) thread #2 - WireTap] Transformer INFO ------------> Processor: Ville de LivraisonCSV------------> Paris ....

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n