首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何捕捉骡子流中的异常

如何捕捉骡子流中的异常
EN

Stack Overflow用户
提问于 2013-03-14 16:57:30
回答 2查看 6.4K关注 0票数 2

我有一个骡子流,可以抛出一个异常(无法连接到连接器,组件抛出异常等等)。当这种情况发生时,骡子流在异常发生的地方停止。我需要捕捉流抛出的任何异常,并发送一个eMail通知,指示发生了异常。(特别是对于运行异步的流,比如从JMS读取)。应该使用流中的哪个元素捕获任何异常并发送eMail?

我试过:

代码语言:javascript
运行
复制
<default-exception-strategy>
        <smtp:outbound-endpoint host="${email.relay.host}"
                    mimeType="text/html" from="${email.support.from" to="${email.support.to}"
                    cc="${email.support.cc}" bcc="${email.support.bcc}" subject="${email.support.subject}">
            </smtp:outbound-endpoint>
    </default-exception-strategy>

但这一点也没有被揭开。我也尝试过:

代码语言:javascript
运行
复制
<exception-type-filter expectedType="java.lang.Exception"></exception-type-filter> 

但是,这似乎只有当流抛出异常(正常流功能发生更改)时才有效。

@ Dossot我添加了以下片段:

我添加了以下片段:

代码语言:javascript
运行
复制
<catch-exception-strategy>
            <smtp:outbound-endpoint host="${email.relay.host}"
                            mimeType="text/html" from="${email.support.from" to="${email.support.to}"
                            cc="${email.support.cc}" bcc="${email.support.bcc}" subject="${email.support.subject}">
            </smtp:outbound-endpoint>
    </catch-exception-strategy>

但是当我启动骡子应用程序时,我得到了一个错误:

根异常堆栈跟踪: org.xml.sax.SAXParseException: cvc-complex-trace.2.4.a:找到无效的内容,以元素“捕获-异常-策略”开头。其中一个'{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor,“http://www.mulesoft.org/schema/mule/core”:抽象出站端点,"http://www.mulesoft.org/schema/mule/core":response,"http://www.mulesoft.org/schema/mule/core":abstract-exception-strategy,"http://www.mulesoft.org/schema/mule/core":abstract-message-info-mapping}‘是预期的。在com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) +3(设置调试级别日志或‘-Dmule.everose.Exception=true’)

我用的是Mule 3.2.2。你能帮忙吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-03-14 16:59:06

在Mule 3.3中,我通常使用catch-exception-strategy

在Mule 3.2和之前的版本中,default-exception-strategy是正确的选择,但可能有些异常没有被正确捕获。在Mule 3.3中对此进行了全面修订。是时候升级了?

票数 2
EN

Stack Overflow用户

发布于 2016-02-10 14:19:29

试着用这个。}从.

代码语言:javascript
运行
复制
<catch-exception-strategy>
<smtp:outbound-endpoint host="${email.relay.host}"
    mimeType="text/html" from="${email.support.from}" to="${email.support.to}" cc="${email.support.cc}" bcc="${email.support.bcc}" subject="${email.support.subject}">
</smtp:outbound-endpoint></catch-exception-strategy>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15415545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档