Apache camel 检索/保留文件-如果使用“捕获”时catch块捕获到异常;尝试捕获;在Apache Camel中使用OneException

Apache camel 检索/保留文件-如果使用“捕获”时catch块捕获到异常;尝试捕获;在Apache Camel中使用OneException,apache-camel,Apache Camel,在下面的路线中,我同时使用了“try..catch”和OneException特性。 如果我的bean中或try block之外的行中存在任何异常,..文件将移动到“.error”,因为我使用了moveFailed选项,但在try block行生成的catch块捕获的异常期间,文件将丢失 1.when server is down 2.when connection timeout 请建议在此类故障/异常期间保留文件的方法 <camelContext streamCach

在下面的路线中,我同时使用了“try..catch”和OneException特性。 如果我的bean中或try block之外的行中存在任何异常,..文件将移动到“.error”,因为我使用了
moveFailed
选项,但在try block行生成的catch块捕获的异常期间,文件将丢失

    1.when server is down
    2.when connection timeout
请建议在此类故障/异常期间保留文件的方法

<camelContext streamCache="false" useMDCLogging="true" id="XXX" xmlns="http://camel.apache.org/schema/spring">
    <streamCaching spoolDirectory="/tmp/cachedir/#camelId#/#uuid#" spoolUsedHeapMemoryThreshold="70" bufferSize="65536" anySpoolRules="true" id="myCacheConfig"/>
    <onException >
        <description>An exception was encountered.</description>
        <exception>java.lang.Exception</exception>
        <log message="somemessage" loggingLevel="INFO"/>
    </onException>   
<route >        
    <from uri="file:D:/Users/Desktop/src?moveFailed=.error" />
    <transform>
        <method ref="somebean" method="somemethod"/>
    </transform>
    <doTry>  
        <to uri="file:D:/Users/Desktop/src" /> 
         <log message="transfered successfully" />           
         <doCatch>
            <exception>java.lang.Exception</exception>
                <log message="Exception occurred and Stopping the Route"/>
                <to uri="controlbus:route?routeId=XXXX&amp;action=stop"/>                       
               <log message="Stopped the Route:XXX"/>
        </doCatch>
    </doTry> 
</route>

遇到异常。
java.lang.Exception
java.lang.Exception

请建议在此类故障/异常期间保留文件的方法

在docatch块中重新显示异常以到达OneException块

<camelContext streamCache="false" useMDCLogging="true" id="XXX" xmlns="http://camel.apache.org/schema/spring">
    <streamCaching spoolDirectory="/tmp/cachedir/#camelId#/#uuid#" spoolUsedHeapMemoryThreshold="70" bufferSize="65536" anySpoolRules="true" id="myCacheConfig"/>
    <onException >
        <description>An exception was encountered.</description>
        <exception>java.lang.Exception</exception>
        <log message="somemessage" loggingLevel="INFO"/>
    </onException>   
<route >        
    <from uri="file:D:/Users/Desktop/src?moveFailed=.error" />
    <transform>
        <method ref="somebean" method="somemethod"/>
    </transform>
    <doTry>  
        <to uri="file:D:/Users/Desktop/src" /> 
         <log message="transfered successfully" />           
         <doCatch>
            <exception>java.lang.Exception</exception>
                <log message="Exception occurred and Stopping the Route"/>
                <to uri="controlbus:route?routeId=XXXX&amp;action=stop"/>                       
               <log message="Stopped the Route:XXX"/>
        </doCatch>
    </doTry> 
</route>
     <doCatch>
        <exception>java.lang.Exception</exception>
            <log message="Exception occurred and Stopping the Route"/>
            <to uri="controlbus:route?routeId=XXXX&amp;action=stop&amp;async=true"/> // async=true to resume/finish this route                       
           <log message="Stopped the Route:XXX"/>
           <throwException  exception="java.lang.Exception"/> // dont know the exact syntax in xml dsl
    </doCatch>

java.lang.Exception
//async=true以恢复/完成此路由
//不知道xml dsl中的确切语法

如果我们重新抛出异常,我应该在什么时候停止路由。请考虑我的场景,以停止在捕捉的路线。还提供Same的原型/结构。您可以使用controlbus的async参数。当使用机上exchange camel停止路由时,它会自动使用优雅关闭功能,并在“终止”路由之前等待(默认为300秒)。