【问题标题】:How to catch any exception in the mule flow如何捕捉骡流中的任何异常
【发布时间】:2013-03-03 04:08:07
【问题描述】:

我有一个可能引发异常的 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 - 我添加了以下 sn-p:

我添加了以下 sn-p :

<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, "@ 之一987654325@":abstract-message-info-mapping}' 是预期的。 在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) 在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) + 3 个以上(设置调试级别日志记录或 '-Dmule.verbose.exceptions=true' 为所有内容)


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

【问题讨论】:

    标签: exception-handling mule flow


    【解决方案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>
    

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • @ddossot 我尝试将其添加到流程中,但在启动 mule 时出现错误。你能确认一下应该添加到哪里吗?
      • @ddossot 谢谢大卫。不幸的是,我无法控制它!没有别的办法吗?
      • Mule 3.2 太老了,我记不太清了:也许可以在传输本身上配置异常策略?
      猜你喜欢
      • 2021-10-17
      • 2019-04-01
      • 2012-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-29
      • 2015-12-19
      • 1970-01-01
      相关资源
      最近更新 更多