如何处理 MULE 中的未检查/运行时异常?
有谁知道如何处理 MULE 中的未检查/运行时异常..?
我的意思是,在我的java代码中,由于某种原因,我“抛出异常”,我希望Mule检测到它并将其路由到正确的流程,在那里我可以记录或打印该异常。
那么,我到底应该在 Mule 配置文件的“流程”中放置什么来实现这一目标。
我的 Java 代码:
public Object xyz (Map payload) throws Exception {
if (payload.isEmpty()) {
throw new Exception ("New Exception") ;
}
}
我的 Mule 配置文件:
<flow name="APIAuthenticate">
<http:inbound-endpoint address="http://localhost:1212/jcore/authorize" transformer-refs="HttpParams" responseTransformer-refs="JavaObjectToJson" contentType="application/json" encoding="UTF-8">
<not-filter>
<wildcard-filter pattern="/favicon.ico"/>
</not-filter>
</http:inbound-endpoint>
<component class="main.java.com.abc.XYZ"/>
</flow>
任何帮助将不胜感激..!
Does anybody know how to handle Unchecked / Runtime Exceptions in MULE..??
I mean, in my java code, for a certain reason , i am "throwing an Exception" and i want Mule to detect it and route it to proper flow , where i can Log or Print that Exception.
So , What exactly should i place in my "flow" in Mule Config File to achieve that.
My Java code :
public Object xyz (Map payload) throws Exception {
if (payload.isEmpty()) {
throw new Exception ("New Exception") ;
}
}
My Mule Config file :
<flow name="APIAuthenticate">
<http:inbound-endpoint address="http://localhost:1212/jcore/authorize" transformer-refs="HttpParams" responseTransformer-refs="JavaObjectToJson" contentType="application/json" encoding="UTF-8">
<not-filter>
<wildcard-filter pattern="/favicon.ico"/>
</not-filter>
</http:inbound-endpoint>
<component class="main.java.com.abc.XYZ"/>
</flow>
Any help will be deeply appreciated..!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在流程中配置默认异常策略应该允许您捕获异常(甚至运行时异常)并处理它们。
有关详细信息,请阅读错误处理参考指南。
Configuring a default-exception-strategy in your flow should allow you to catch the exceptions (even runtime ones) and deal with them.
Read the error handling reference guide for more info.
好吧..我做了一些尝试,我发现
当异常抛出时,需要一个异常策略,例如default-exception-strategy或< strong>custom-exception-strategy 是必需的,它将把流程路由到某个可以处理它并执行所需操作的类。
但是当我们返回异常时(如下所示),那么我们可以使用Mule的exception-payload-filter或choice属性来处理它。
如果我错了请纠正我..??
另外,如果这个问题还有其他答案,请留言。
Ok..i did some hit and trial and i figured out that
When the Exception is thrown, an Exception Strategy is required like default-exception-strategy OR custom-exception-strategy is required, that would route the flow to some Class that would handle it and do required Actions.
But When we Return an Exception (like below), then we can use the exception-payload-filter or choice attribute of Mule to handle it.
Please Correct me if i am wrong..??
Also if there are other answers to this question, please be kind to put them..