Skip to content

Instantly share code, notes, and snippets.

@satyaj
Created January 22, 2020 10:00
Show Gist options
  • Save satyaj/9187ddce4217375fe6634ed6106a2c26 to your computer and use it in GitHub Desktop.
Save satyaj/9187ddce4217375fe6634ed6106a2c26 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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">
<!-- Define a traditional camel context here -->
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties" location="route.properties"/>
<!-- EXCLUDE-BEGIN -->
<endpoint id="csv2json" uri="dozer:csv2json2?sourceModel=org.acme.Customer&amp;targetModel=org.globex.Account&amp;marshalId=json&amp;unmarshalId=csv&amp;mappingFile=transformation.xml"/>
<!-- CSV Input & JSon OutPut DataFormat -->
<dataFormats>
<bindy classType="org.acme.Customer" id="csv" type="Csv"/>
<json id="json" library="Jackson"/>
</dataFormats>
<restConfiguration bindingMode="off" component="servlet" contextPath="/rest"/>
<rest apiDocs="true"
id="rest-130579d7-1c1b-409c-a496-32d6feb03006" path="/service">
<post id="32d64e54-9ae4-42d3-b175-9cfd81733379" uri="/customers">
<to uri="direct:inbox"/>
</post>
</rest>
<!--
Transformation Endpoint doing csv2java conversion
Step 1 : csv record is converted java using camel bindy
Step 2 : Dozer transformation of Customer to Account
Step 3 : Java to Json conversion using json jackson
-->
<route id="_route1" streamCache="true">
<!-- Consume files from input directory -->
<from id="_from1" uri="direct:inbox"/>
<onException id="_onException1">
<exception>java.lang.IllegalArgumentException</exception>
<handled>
<constant>true</constant>
</handled>
<log id="_log1" message=">> Exception : ${body}"/>
<setExchangePattern id="_setExchangePattern1" pattern="InOnly"/>
<to id="_to1" uri="amqp:queue:errorQueue"/>
</onException>
<split id="_split1">
<tokenize token=";"/>
<to id="_to2" ref="csv2json"/>
<setExchangePattern id="_setExchangePattern2" pattern="InOnly"/>
<to id="_to3" uri="amqp:queue:accountQueue"/>
<log id="_log2" message=">> Completed JSON: ${body}"/>
</split>
<transform id="_transform1">
<constant>Processed the customer data</constant>
</transform>
</route>
<!-- EXCLUDE-END -->
</camelContext>
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment