Created
September 28, 2016 06:13
-
-
Save honghuac/ba4e0c7b13bbb588b778ac35a188a78f to your computer and use it in GitHub Desktop.
Lab 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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://camel.apache.org/schema/cxf" | |
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://camel.apache.org/schema/cxf | |
http://camel.apache.org/schema/cxf/camel-cxf-spring.xsd | |
http://camel.apache.org/schema/spring | |
http://camel.apache.org/schema/spring/camel-spring.xsd | |
http://cxf.apache.org/transports/http-jetty/configuration | |
http://cxf.apache.org/schemas/configuration/http-jetty.xsd"> | |
<cxf:cxfEndpoint id="customerWebService" address="http://localhost:9090/ws/customerService" | |
serviceClass="org.fuse.usecase.service.CustomerWS" | |
loggingFeatureEnabled="false"> | |
</cxf:cxfEndpoint> | |
<cxf:rsServer id="customerRestService" address="http://localhost:9191/rest" | |
serviceClass="org.fuse.usecase.service.CustomerRest" | |
loggingFeatureEnabled="false"> | |
<cxf:providers> | |
<ref bean="jsonProvider"/> | |
</cxf:providers> | |
</cxf:rsServer> | |
<cxf:rsClient id="customerRestServiceClient" address="http://localhost:9191/rest" | |
loggingFeatureEnabled="false" serviceClass="org.fuse.usecase.service.CustomerRest"> | |
<cxf:providers> | |
<ref bean="jsonProvider"/> | |
</cxf:providers> | |
</cxf:rsClient> | |
<bean id="reconcileData" class="org.fuse.usecase.AccountAggregator"/> | |
<bean id="customerWSImplBean" class="org.fuse.usecase.service.CustomerWSImpl"/> | |
<bean id="customerRestImplBean" class="org.fuse.usecase.service.CustomerRestImpl"/> | |
<bean id="processorBean" class="org.fuse.usecase.ProcessorBean"/> | |
<bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/> | |
<camelContext trace="false" xmlns="http://camel.apache.org/schema/spring"> | |
<propertyPlaceholder id="properties" location="fabric8/route.properties"/> | |
<threadPool id="restPool" poolSize="10" maxPoolSize="20" maxQueueSize="100" | |
threadName="restThreadPool"/> | |
<threadPool id="wsPool" poolSize="10" maxPoolSize="20" maxQueueSize="100" | |
threadName="wsThreadPool"/> | |
<!-- | |
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 | |
--> | |
<endpoint | |
uri="dozer:csv2json?sourceModel=org.acme.Customer&targetModel=org.globex.Account&marshalId=json&unmarshalId=csv&mappingFile=transformation.xml" | |
id="csv2json"/> | |
<!-- CSV Input & JSon OutPut DataFormat --> | |
<dataFormats> | |
<bindy id="csv" type="Csv" classType="org.acme.Customer"/> | |
<json id="json" library="Jackson"/> | |
</dataFormats> | |
<!-- Route Definition CSV to JSON --> | |
<route> | |
<!-- Consume files from input directory --> | |
<from uri="file:{{fileInput}}?fileName=customers.csv&noop=true"/> | |
<onException> | |
<exception>java.lang.IllegalArgumentException</exception> | |
<handled> | |
<constant>true</constant> | |
</handled> | |
<to uri="file:{{fileError}}?fileName=csv-record-${date:now:yyyyMMdd}.txt"/> | |
</onException> | |
<split parallelProcessing="true"> | |
<tokenize token="\n"/> | |
<to ref="csv2json"/> | |
<log message=">> Split : ${threadName}"/> | |
<to uri="file:{{fileOutput}}?fileName=account-${property.CamelSplitIndex}.json"/> | |
</split> | |
</route> | |
<!-- Multicast the account to the REST & WS to aggregate the result --> | |
<route> | |
<from uri="file:{{fileOutput}}"/> | |
<convertBodyTo type="String"/> | |
<unmarshal> | |
<json library="Jackson" unmarshalTypeName="org.globex.Account"/> | |
</unmarshal> | |
<multicast strategyRef="reconcileData"> | |
<to uri="direct://callRestEndpoint"/> | |
<to uri="direct://callWSEndpoint"/> | |
</multicast> | |
<log loggingLevel="INFO" | |
message=">> Aggregated result: Account : ${body.clientId}, ${body.salesRepresentative}; Company : ${body.company.name}, ${body.company.geo}, ${body.company.active}; Contact : ${body.contact.firstName}, ${body.contact.lastName}, ${body.contact.streetAddr}, ${body.contact.city}, ${body.contact.state}, ${body.contact.zip}, ${body.contact.phone}"/> | |
<!-- <to uri="direct:insertDB"/> --> | |
</route> | |
<!-- REST Service --> | |
<route> | |
<from uri="cxfrs:bean:customerRestService"/> | |
<threads executorServiceRef="restPool"> | |
<log message=">> REST Service Thread : ${threadName}"/> | |
<bean ref="customerRestImplBean" method="enrich"/> | |
</threads> | |
</route> | |
<!-- Web Service --> | |
<route> | |
<from uri="cxf:bean:customerWebService"/> | |
<threads executorServiceRef="wsPool"> | |
<log message=">> Web Service Thread : ${threadName}"/> | |
<bean ref="customerWSImplBean" method="updateAccount"/> | |
</threads> | |
</route> | |
<!-- Call WebService Client --> | |
<route> | |
<from uri="direct://callWSEndpoint"/> | |
<to uri="cxf:bean:customerWebService"/> | |
<!-- | |
<log loggingLevel="INFO" | |
message=">> WebService Response : ${body[0].id}, ${body[0].salesContact}, ${body[0].company.geo}, ${body[0].contact.firstName}, ${body[0].contact.lastName} "/> | |
--> | |
</route> | |
<!-- Call REST Client --> | |
<route> | |
<from uri="direct://callRestEndpoint"/> | |
<onException> | |
<exception>java.lang.Exception</exception> | |
<redeliveryPolicy maximumRedeliveries="1"/> | |
<handled> | |
<constant>true</constant> | |
</handled> | |
<log message=">> Error : ${exception.message}, ${exception.stacktrace}"/> | |
</onException> | |
<setHeader headerName="Content-Type"> | |
<constant>application/json</constant> | |
</setHeader> | |
<setHeader headerName="Accept"> | |
<constant>application/json</constant> | |
</setHeader> | |
<setHeader headerName="CamelHttpMethod"> | |
<constant>POST</constant> | |
</setHeader> | |
<setHeader headerName="CamelHttpPath"> | |
<constant>/customerservice/enrich</constant> | |
</setHeader> | |
<setHeader headerName="CamelCxfRsUsingHttpAPI"> | |
<constant>True</constant> | |
</setHeader> | |
<setHeader headerName="originalBody"> | |
<simple>${body}</simple> | |
</setHeader> | |
<inOut uri="cxfrs:bean:customerRestServiceClient"/> | |
<bean beanType="org.fuse.usecase.ProcessorBean" method="convertEntityToString"/> | |
<unmarshal> | |
<json library="Jackson" unmarshalTypeName="org.globex.Account"/> | |
</unmarshal> | |
<setBody> | |
<simple>${body}</simple> | |
</setBody> | |
</route> | |
</camelContext> | |
</beans> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment