2016-11-08 8 views
1

두 개의 파이프 라인이있는 Camel에서 멀티 캐스트 경로를 사용하고 있습니다. 하나의 파이프 라인은 데이터를 데이터베이스에 추가하고 다른 파이프 라인은 파일에 대한 일부 쓰기 작업을 수행합니다. 오류 또는 오류 발생시 전체 프로세스를 롤백해야한다는 요구 사항. db 삽입을 성공적으로 롤백했지만 파일에서 수행 된 쓰기 작업을 롤백하는 방법을 찾을 수 없습니다. 누구나 롤백 프로세스를 도와 줄 수 있습니까?Apache Camel 트랜잭션을 사용할 때 파일 쓰기를 롤백하는 방법은 무엇입니까?

<routeContext id="s1Route" xmlns="http://camel.apache.org/schema/spring"> 
    <route id="sRoute"> 
     <from uri="activemq:queue:{{s.queue}}" /> 
     <log message="Message received from myprocess queue is ${body}"></log> 
     <unmarshal ref="gsonUnmarshelling"></unmarshal> 
     <bean beanType="com.***.upload.***.GetMyBean" 
      method="process(com.**.upload.beans.MyEvenets,${exchange})" /> 
     <log message="Multicasting data ${body} to file system and database" /> 
     <multicast parallelProcessing="true"> 
      <pipeline> 
       <choice> 
        <when> 
         <simple>${properties:s.write.file} == true</simple> 
         <setHeader headerName="path"> 
          <simple>${properties:s.write.folder}</simple> 
         </setHeader> 
         <log message="Going to write to file : ${body}"></log> 
         <bean beanType="com.***.upload.processors.ToFile" 
          method="process(${exchange},com.***.upload.beans.MyFile)" /> 
         <to uri="file://?fileExist=Append"></to> 
        </when> 
       </choice> 
      </pipeline> 
      <pipeline> 
       <log message="Going to insert in database"></log> 
       <transform> 
        <method ref="insertBean" method="MyBatchInsertion"></method> 
       </transform> 
       <choice> 
        <when> 
         <simple>${in.header.myCount} == ${properties:batch.size}</simple> 
         <to uri="sql:{{sql.my.insertBatch}}?batch=true"></to> 
         <log message="Inserted rows ${body}"></log> 
        </when> 
       </choice> 
      </pipeline> 
     </multicast> 
    </route> 
</routeContext> 

답변