48.16. Spring XML 사용
Spring을 즐겨 찾는 DSL 언어로 사용하여 camel-bindy에 사용할 경로를 선언하기 쉽습니다. 다음 예제에서는 첫 번째가 파일에서 레코드를 선택하고 콘텐츠를 요약하고 모델에 바인딩하는 두 경로를 보여줍니다. 그러면 결과가 pojo로 전송되고(특별하지 않음) 큐에 배치합니다.
두 번째 경로는 큐에서 pojos를 추출하고 콘텐츠를 마샬링하여 csv 레코드가 포함된 파일을 생성합니다. 위의 예는 Camel 2.16 이상을 사용하는 것입니다.
Spring dsl
<?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>
참고
모델 클래스가 직렬화 가능 항목을 구현했는지 확인하십시오. 그렇지 않으면 큐 관리자가 오류를 발생시킵니다.