首页 文章

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

提问于
浏览
2

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

我试过了:

<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>

但这根本没有开始 . 我也尝试过:

<exception-type-filter expectedType="java.lang.Exception"></exception-type-filter>

但这似乎仅在流抛出异常(正常流功能改变)时起作用 .

@David Dossot - 我添加了以下代码段:

我添加了以下代码段:

<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>

但是在启动mule应用程序时我得到了一个错误:

根异常堆栈跟踪:org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:找到以元素'catch-exception-strategy'开头的无效内容 . 其中一个'{“_”http://www.mulesoft.org/schema/mule/core ":abstract-message-processor, " http://www.mulesoft.org/schema/mule/core ":abstract-outbound-endpoint, " 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} ' is expected. at 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 more (set debug level logging or ' -Dmule.verbose.exceptions = true'for everything)


我正在使用Mule 3.2.2 . 你能帮忙吗?

2 回答

  • 2

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

    在Mule 3.2和之前, default-exception-strategy 是正确的选择,但有些例外可能没有被正确捕获 . 这已在Mule 3.3中进行了彻底检查 . 是时候升级?

  • 1

    尝试使用这个 . 来自 .

    <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>
    

相关问题