简体   繁体   中英

Handling specific exceptions within a mule flow

I have a JAX-RS service wrapped in a mule v3.2.1 flow which may trigger exceptions which I would like to capture and process. I would prefer to send the exception to another class and return an OutboundProperty with an http status of 500. Here's what I've got so far:

<flow name="someFlow">
    <...do some stuff...>
    <custom-exception-strategy class="com.myCustomExceptionHandler>
    </default-exception-strategy>
</flow>

myCustomExceptionHandler.handleException() is never called when I trigger an exception. And it is unclear to me how I repackage the mule message to return an http response.

Can anyone please provide some ideas on how to get this to work?

---- update ----

The exception will be a org.mule.api.expression.RequiredValueException, which is thrown when evaluate() is called by an instance of MuleExpressionManager inside a custom message processor:

public class RequestCheckWithAppMessageProcessor
implements FlowConstructAware, MuleContextAware, Disposable, Initialisable, Startable, Stoppable, MessageProcessor

The myCustomExceptionHandler class extends AbstractMessagingExceptionStrategy.

Try removing the default-exception-strategy tag. I'm not very familiar with mule 3.2.1 but from the tests I get that the custom-exception-strategy should not be nested within the default one.

使用catch-exception-strategy并编写一个自定义Transformer,根据Excption类型接收DefaultExceptionStrategy作为MuleMessage中的异常有效负载,映射错误代码

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM