• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Aimaf
 

Aimaf

on

  • 2,844 views

 

Statistics

Views

Total Views
2,844
Views on SlideShare
2,583
Embed Views
261

Actions

Likes
0
Downloads
22
Comments
0

7 Embeds 261

http://teckenta.wordpress.com 146
http://kirandir.com 89
http://swazzy.com 10
http://alex4u2nv.com 8
http://www.linkedin.com 5
http://twitter.com 2
https://www.linkedin.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Aimaf Aimaf Presentation Transcript

  • Application: B BPM BAM Application: A
  • é 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 dintégration avec une formation minimale grâce à un langage Java simple ou avec XML
  • ## 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/.....
  • <groupId>fr.aimaf</groupId> <artifactId>Example</artifactId> <packaging>bundle</packaging> <version>0.1</version> <name>Aimaf Example :: Camel OSGi Bundle</name>
  • Expéditeur: DestinataireApplication Application A B Queue Queue Queue
  • <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>
  • 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 ... }}
  • 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 : InOnlyINFO Exchange ID : ID-saad-local-51012-1303566625671-0-2INFO ---------- Here Starts Headers ----------INFO Key : camelfilenameonly Value : livraison.csvINFO Key : camelfileparent Value : src/dataINFO Key : camelfilename Value : livraison.csvINFO Key : camelfileabsolute Value : falseINFO Key : camelfilelength Value : 115INFO Key : camelfilerelativepath Value : livraison.csvINFO Key : camelfilepath Value : src/data/livraison.csvINFO Key : camelfilelastmodified Value : Sat Apr 16 08:26:18 CEST 2011INFO Key : camelfileabsolutepath Value : /users/saadrguig/Desktop/CAMEL-CSV-TEST/src/data/livraison.csvINFO ---------- Here Starts Properties -------INFO Key : CamelBatchComplete Value : trueINFO Key : CamelBatchSize Value : 1INFO Key : CamelCreatedTimestamp Value : Sat Apr 23 15:50:27 CEST 2011INFO Key : CamelFileExchangeFile Value : GenericFile[livraison.csv]INFO Key : Propriete 1 Value : Contenu de La propriete 1INFO 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>
  • 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....