이는 Spring을 선호하는 DSL 언어로 사용하여 카멜-바인드에 사용할 경로를 선언하기가 매우 쉽습니다. 다음 예제에서는 첫 번째 경로가 파일에서 레코드를 선택하는 두 개의 경로를 보여줍니다. 내용을 요약하여 모델에 바인딩합니다. 그 결과는 pojo에게 전송되고 (특별한 것은 아무것도 없음) 큐에 배치됩니다.
두 번째 경로는 큐에서 pojos를 추출하고 콘텐츠를 마샬링하여 csv 레코드를 포함하는 파일을 생성합니다. 위 예제는 Camel 2.16 이상을 사용하는 것입니다.
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- Queuing engine - ActiveMq - work locally in mode virtual memory -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="vm://localhost:61616"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<bindy id="bindyDataformat" type="Csv" classType="org.apache.camel.bindy.model.Order"/>
</dataFormats>
<route>
<from uri="file://src/data/csv/?noop=true" />
<unmarshal ref="bindyDataformat" />
<to uri="bean:csv" />
<to uri="activemq:queue:in" />
</route>
<route>
<from uri="activemq:queue:in" />
<marshal ref="bindyDataformat" />
<to uri="file://src/data/csv/out/" />
</route>
</camelContext>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- Queuing engine - ActiveMq - work locally in mode virtual memory -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="vm://localhost:61616"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<bindy id="bindyDataformat" type="Csv" classType="org.apache.camel.bindy.model.Order"/>
</dataFormats>
<route>
<from uri="file://src/data/csv/?noop=true" />
<unmarshal ref="bindyDataformat" />
<to uri="bean:csv" />
<to uri="activemq:queue:in" />
</route>
<route>
<from uri="activemq:queue:in" />
<marshal ref="bindyDataformat" />
<to uri="file://src/data/csv/out/" />
</route>
</camelContext>
</beans>
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow