0
在我的骆驼路由中,我正在对现有的bundle进行直接-vm调用。在那项服务中,他们已经处理了异常情况并设置了一些自定义错误消息。当该服务发生任何异常时,它们将发送如下所示的错误消息。在Apache骆驼中修改处理的异常错误消息
{
"errorCode": "400",
"errorMessage": "Unknown error"
}
但我需要根据收到的故障消息形成我自己的自定义故障消息。但是,一旦第二包发生异常,我无法收回故障信息并对其进行修改。下面是我的路线。
<route handleFault="true" streamCache="true" id="route1">
<from uri="cxfrs://bean://testCxf?synchronous=true"/>
<log message="The consumer message ${body}"/>
<bean ref="requestValidator" method="validateRequest"/>
<to uri="direct-vm:retrieveData"/>
<bean ref="validateResponse" method="validate"/>//need to manipulate the fault message coming from bundle 2 in this bean.
<onException>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<bean ref="faultMapper" method="mapFault"/>
</onException>
</route>
下面是现有的直接:vm路由。
<route handleFault="true" streamCache="true" id="route2">
<from uri="direct-vm:retrieveData"/>
<bean ref="manipulateData" method"manipulate"/>
<onException>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<bean ref="faultMapper1" method="mapFault1"/>
</onException>
</route>
我需要直接-VM call.How后拦截在类faultmapper1映射故障,在我ROUTE1以达致这?我不会允许在现有的第二包中更改任何内容。提前致谢。
我不认为这是可能的。但是更好的设计将是在单独的路由中执行定制错误消息处理,这取决于例如特定报头会生成自定义错误消息。当您的路由发出请求并且发生错误时,将使用标题等等。更容易改变。 –