Mule-Rest异常处理

Mule-Rest异常处理,mule,Mule,骡流: <jersey:resources doc:name="REST"> <component class="com.test.qb.rest.MapIIFContent"/> <jersey:exception-mapper class="com.test.qb.exception.IIFExceptionMapper" /> </jersey:resources> <catch-exception-strategy doc:name=

骡流:

<jersey:resources doc:name="REST">
<component class="com.test.qb.rest.MapIIFContent"/>
<jersey:exception-mapper class="com.test.qb.exception.IIFExceptionMapper" />
</jersey:resources>
<catch-exception-strategy doc:name="Audit Exception" >      
    <set-variable variableName="status" value="Failure" doc:name="Status"/>
    <flow-ref name="QB:audit" doc:name="audit"/>
    <http:response-builder status="500" contentType="application/json" doc:name="Status Code"/>
</catch-exception-strategy>
<logger message=" ===Reached here====" level="INFO" doc:name="Logger"/> <!-- Line 10-->
当我运行这个程序时,它进入JavaREST组件中的catch块,错误状态为500。 但在骡子流中,我希望流量应该达到

'捕获异常策略文档:name=“审计异常”>


阻塞,但它没有到达那里,而是到达第10行。如何处理此问题?

我让rest组件抛出选中的自定义异常,而不是返回rest响应状态:

try{
    String s =null;
    s.toString();
} catch (IIFException e) {
    throw new IIFException(e.toString(),e.getCause());
}
return Response.ok(res).build();
在我的例外流中,它是:

<catch-exception-strategy doc:name="Audit Exception" >
    <expression-component doc:name="Create error response"><![CDATA[#[payload = "{\"status\":\"error\", \"message\":\"" + exception.cause.message + "\"}"]]]></expression-component>
    <http:response-builder status="500" contentType="application/json" doc:name="Status Code"/>
</catch-exception-strategy>


奇怪的是,您既有
异常映射器
又有
捕获异常策略
:不是在
MapIIFContent
中创建了
500
响应吗?如果删除
jersey:exception mapper
,会发生什么情况:
捕获异常策略是否有效?如果不是,则意味着
jersey:resources
异常被jersey拦截,永远不会到达Mule。@DavidDossot在注释jersey:exception mapper后,没有更改,相同的流继续,捕获异常策略不起作用,即问题,jersey异常没有到达Mule。如何从jersey与mule通信?这看起来是一条路,基本上组件需要抛出一个异常,mule异常策略才能生效。
<catch-exception-strategy doc:name="Audit Exception" >
    <expression-component doc:name="Create error response"><![CDATA[#[payload = "{\"status\":\"error\", \"message\":\"" + exception.cause.message + "\"}"]]]></expression-component>
    <http:response-builder status="500" contentType="application/json" doc:name="Status Code"/>
</catch-exception-strategy>