Create Camel Context

Create camel-context.xml, like shown below, to provide context for Spring. 

This file can also be used to create routes – they can be defined directly here. (Another way to define a route is to put it in a separate XML file and reference it from this file.)

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xmlns:pfx="http://www.pricefx.eu/schema/pfx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd http://www.pricefx.eu/schema/pfx http://www.pricefx.eu/schema/pfx.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"> <import resource="mappers-filters.xml"/> <camelContext xmlns="http://camel.apache.org/schema/spring" useMDCLogging="true"> <contextScan/> </camelContext> </beans>

Add Routes

<util:list id="dataHeader"> <value>sku</value> <value>name</value> </util:list> <bean id="csvWithHeaderFormat" class="org.apache.camel.model.dataformat.CsvDataFormat"> <property name="useMaps" value="true"/> <property name="header" ref="dataHeader"/> <property name="delimiter" value=","/> <property name="skipHeaderRecord" value="true"/> </bean> <pfx:csv-to-list id="csvExportProducts" dataFormat="csvWithHeaderFormat"> <pfx:dsLoad objectType="P" businessKeys="sku" mapper="productMapper"/> </pfx:csv-to-list> <pfx:loadMapper id="carsMapper" convertEmptyStringToNull="true"> <pfx:simple expression="Cars" out="name"/> <pfx:body in="sku"/> <pfx:body in="label" out="attribute1"/> <pfx:body in="price" out="attribute2"/> </pfx:loadMapper> <bean id="addRoutesRoute" class="net.pricefx.integration.route.AddRoutesRoute"> <property name="routeInputPath" value="routes"/> <property name="routeOutputPath" value="camel"/> <property name="delayInMillis" value="30000"/> </bean> <camelContext xmlns="http://camel.apache.org/schema/spring" useMDCLogging="true"> <contextScan/> <route> <from uri="file:src/data?noop=true"/> <to uri="direct://csvExportProducts"/> <log message="Saved products"/> </route>



IntegrationManager version 5.8.0