This document describes an integration framework and its components. It includes:
- FUSE ESB as the integration bus based on JBI and OSGi standards.
- ActiveMQ as the message broker based on JMS.
- CXF for creating or consuming web services.
- Camel as the mediation router for creating integration patterns with a simple Java or XML DSL.
- Details on configuring ActiveMQ and Camel within a OSGi container.
- Code examples of using Camel routes and processors to integrate and transform messages between endpoints.
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/.....
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