2

我有一个可能引发异常的 mule 流(无法连接到连接器、组件引发异常等)。发生这种情况时,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-端点,“ http://www.mulesoft.org/schema/mule/core ”:响应,“ 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 的 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)。 internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) + 3 个以上(设置调试级别日志记录或'- Dmule.verbose.exceptions=true' 为一切)


我正在使用骡子 3.2.2。你能帮忙吗?

4

2 回答 2

2

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

在 Mule 3.2 及之前的版本中,default-exception-strategy这是正确的选择,但可能无法正确捕获某些异常。这已在 Mule 3.3 中进行了大修。是时候升级了?

于 2013-03-14T16:59:06.187 回答
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>
于 2016-02-10T14:19:29.160 回答