我需要逐行解析文件。每行使用拆分器组件单独处理。处理完所有行后,我需要将文件复制到 done_folder。如果所有行都正确处理,则一切正常。但是,如果行不正确,那么我会收到以下有关回滚的警告,并且文件不会复制到 done_folder 警告:
WARN (Camel (com.company.realcardparser) thread #0 - file://project/src/test/resources/working_folder) [GenericFileOnCompletion] Rollback file strategy: org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy@41a7d9e7 for file: GenericFile[237file09062012-qa.csv]
我的骆驼配置:
<camelContext id="com.company.realcardparser" xmlns="http://camel.apache.org/schema/spring" trace="true">
<routeContextRef ref="idtProxyRoute"/>
<endpoint id="fileParserInputEndPoint" uri="file:${idt.proxy.real.card.parser.folder.test.input}?delete=true&readLock=${idt.proxy.real.card.parser.readLock}&readLockCheckInterval=${idt.proxy.real.card.parser.readLockCheckInterval}&readLockTimeout=${idt.proxy.real.card.parser.readLockTimeout}&delay=${idt.proxy.real.card.parser.delay}"/>
<endpoint id="fileParserOutputEndPoint" uri="file:${idt.proxy.real.card.parser.folder.test.output}"/>
<endpoint id="fileParserOutputFailedEndPoint" uri="file:${idt.proxy.real.card.parser.folder.test.output.failed}"/>
</camelContext>
<bean id="idtTxRequired" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="transactionManager"/>
<property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"/>
</bean>
<routeContext id="idtProxyRoute" xmlns="http://camel.apache.org/schema/spring">
<route id="idtRealCardParserRoute">
<from ref="fileParserInputEndPoint"/>
<transacted ref="idtTxRequired"/>
<split>
<method bean="realCardParser" method="handle"/>
<to uri="bean:realCardFinalizer"/>
</split>
<to ref="fileParserOutputEndPoint"/>
</route>
</routeContext>
如何让骆驼忽略异常?我试图用 try/catch 块包围分离器,但没有帮助。