...
Compare to a simple camel project, the spring beans tag has been enriched with new namespaces :
- spring-osgi (http://www.springframework.org/schema/osgi
...
- ) which is used by OSGI blueprint services
- camel-osgi (http://camel.apache.org/schema/osgi
...
- ) who will allow to integrate camel with OSGI world
- cxf (http://camel.apache.org/schema/cxf
...
- ) to integrate CXF architecture with Camel
Now, that the schema/namespaces are declared, we can start to add additional stuffs like import resources, beans reference, ... that our routing engine will use.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<camel:camelContext trace="true" xmlns="http://camel.apache.org/schema/osgi"> (1) <camel:route> <camel:from uri="file://d:/temp/data/reportincident/?move=d:/temp/donebackup/${date:now:yyyyMMdd}/${file:name.noext}.bak" /> (2) <camel:setHeader headerName="origin"> (3) <camel:constant>file</camel:constant> </camel:setHeader> <camel:unmarshal ref="bindyDataformat" /> (4) <camel:to uri="queuingservice:queue:in" /> (5) </camel:route> ... |
Remarks :
(1) - camel:camelContext tag is used to instantiate the camelcontext at the launch of the bundle. The trace parameter is defined as true so the tracing will be available on the console
(2) - The from uri="file" informs Camel that a file component must be started and it will listen for incoming files deposited in the directory d:/temp/data/reportincident
. When the file is processed (end of the Camel route), then it is moved to the directory d:/temp/donebackup/
where the file is renamed (.bak extension is added). During the process of the file and till the route is not finished, the file will be locked
(3) - A header is added to the message with the property origin
setted to file
(4) - To parse the content of the CSV file into a collection of incident objects, we use the action unmarshall
where the reference provided corresponds to the bean BindyCsvDataFormat instantiated by Spring
(5) - The result of the parsing process is copied as a message in the queue:in
...
Code Block | ||||
---|---|---|---|---|
| ||||
... <instructions> <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> <Import-Package> (1) META-INF.cxf, META-INF.cxf.osgi, META-INF.wsdl, org.apache.commons.logging, org.apache.camel;version="[2.0,2.2)", org.apache.camel.component;version="[2.0,2.2)", org.apache.camel.component.cxf;version="[2.0,2.2)", org.apache.camel.component.cxf.converter;version="[2.0,2.2)", org.apache.camel.component.jms;version="[2.0,2.2)", org.apache.camel.converter;version="[2.0,2.2)", org.apache.camel.converter.jaxp;version="[2.0,2.2)", org.apache.camel.converter.stream;version="[2.0,2.2)", org.apache.camel.dataformat.bindy;version="[2.0,2.2)", org.apache.camel.dataformat.bindy.csv;version="[2.0,2.2)", org.apache.camel.example.reportincident, org.apache.camel.example.reportincident.model, org.apache.camel.example.reportincident.service, org.apache.camel.processor;version="[2.0,2.2)", org.apache.activemq.camel.component;${activemq.osgi.version}, org.apache.activemq.camel.converter;${activemq.osgi.version}, org.apache.activemq.pool, org.apache.cxf, org.apache.cxf.binding, org.apache.cxf.binding.corba, org.apache.cxf.binding.soap, org.apache.cxf.binding.soap.spring, org.apache.cxf.bus, org.apache.cxf.bus.resource, org.apache.cxf.bus.spring, org.apache.cxf.buslifecycle, org.apache.cxf.catalog, org.apache.cxf.configuration, org.apache.cxf.configuration.spring, org.apache.cxf.endpoint, org.apache.cxf.headers, org.apache.cxf.management, org.apache.cxf.management.jmx, org.apache.cxf.phase, org.apache.cxf.resource, org.apache.cxf.transport, org.apache.cxf.transport.http, org.apache.cxf.transport.http.policy, org.apache.cxf.transport.http_jetty, org.apache.cxf.transport.jmshttp_osgi, org.apache.cxf.transportstransport.httpjms, org.apache.cxf.transports.workqueuehttp, org.apache.cxf.wsdlworkqueue, org.apache.cxf.wsdl11wsdl, org.apache.servicemix.cxf.transport.http_osgiwsdl11, org.springframework.beans.factory.config, * </Import-Package> <Private-Package>org.apache.camel.example.reportincident.internal</Private-Package> (2) </instructions> ... |
...
In this section of the tutorial, we have discussed how to design the routing between endpoints/components of our application using Camel Spring DSL language. We have also investigated how to setup the infrastructure required to work with ActiveMq, any other queuing engine and CXF. In the next chapter, we will see how to create the web application, package the solution and deploy it on ServiceMix.
Links
...
...
...
- 2b : add infrastructure and routing
- Part
...
#Resources
Attachments patterns .*part2.zip