Skip to content

Instantly share code, notes, and snippets.

@satyaj
Created November 27, 2019 07:57
Show Gist options
  • Save satyaj/2e3dc1b0f6447f88e089f20800b8cec1 to your computer and use it in GitHub Desktop.
Save satyaj/2e3dc1b0f6447f88e089f20800b8cec1 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2014-2017, Red Hat, Inc. and/or its affiliates, and individual
contributors by the @authors tag.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Configures the Camel Context-->
<beans xmlns="http://www.springframework.org/schema/beans"
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">
<camelContext id="_camelContext1" xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties" location="fabric8/route.properties"/>
<!--
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
-->
<!-- 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>
<route id="_route1">
<!-- Consume files from input directory -->
<from id="_from1" uri="file:{{fileInput}}?fileName=customers.csv&amp;noop=true"/>
<onException id="_onException1">
<exception>java.lang.IllegalArgumentException</exception>
<handled>
<constant>true</constant>
</handled>
<to id="_to1" uri="file:{{fileError}}?fileName=csv-record-${date:now:yyyyMMdd}.txt"/>
</onException>
<split id="_split1">
<tokenize token="\n"/>
<to id="_to2" ref="csv2json"/>
<to id="_to3" uri="file:{{fileOutput}}?fileName=account-${property.CamelSplitIndex}.json"/>
</split>
</route>
<!-- EXCLUDE-END -->
</camelContext>
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment