Camel Spring DSL 上未捕获异常
Exceptions not been catched on Camel Spring DSL
我正在使用 Camel 路由将 csv 文件转换为 XML,使用 Spring DSL。我使用带注释的 class 和 .xsd 的 JAXB 来验证结果。
在路线上,我使用了 doTry/doCatch 代码块。如果发生任何异常,我会将实际消息写入文件。我还使用自定义过程将 CSV 文件转换为我注释 class 的实例。我的问题如下:
例如,如果我更改了 .xsd 文件中的名称,则会抛出异常,并且在路由中会执行 doCatch 片段并将消息写入文件。但是,如果我的处理器抛出异常,则 doCatch 将被忽略。
<route>
<from uri="file://C:/a"/>
<doTry>
<unmarshal><csv delimiter=","/></unmarshal>
<process ref="myProccesor"/>
<marshal ref="jb"></marshal>
<to uri="file://C:/ok"/>
<doCatch>
<exception>java.lang.Exception</exception>
<to uri="file://C:/nok"/>
</doCatch>
</doTry>
</route>
你确定吗,doCatch 被忽略了?它应该捕获您的异常,但您必须告诉骆驼异常已处理。没有这头骆驼就抓不住它。在<exception></exception>
之后添加
<handled>
<constant>true</constant>
</handled>
我正在使用 Camel 路由将 csv 文件转换为 XML,使用 Spring DSL。我使用带注释的 class 和 .xsd 的 JAXB 来验证结果。
在路线上,我使用了 doTry/doCatch 代码块。如果发生任何异常,我会将实际消息写入文件。我还使用自定义过程将 CSV 文件转换为我注释 class 的实例。我的问题如下: 例如,如果我更改了 .xsd 文件中的名称,则会抛出异常,并且在路由中会执行 doCatch 片段并将消息写入文件。但是,如果我的处理器抛出异常,则 doCatch 将被忽略。
<route>
<from uri="file://C:/a"/>
<doTry>
<unmarshal><csv delimiter=","/></unmarshal>
<process ref="myProccesor"/>
<marshal ref="jb"></marshal>
<to uri="file://C:/ok"/>
<doCatch>
<exception>java.lang.Exception</exception>
<to uri="file://C:/nok"/>
</doCatch>
</doTry>
</route>
你确定吗,doCatch 被忽略了?它应该捕获您的异常,但您必须告诉骆驼异常已处理。没有这头骆驼就抓不住它。在<exception></exception>
之后添加
<handled>
<constant>true</constant>
</handled>