【问题标题】:Need Help for interpretation of Error Handling Scenario for Mulesoft需要帮助解释 Mulesoft 的错误处理方案
【发布时间】:2020-06-24 14:18:49
【问题描述】:

我的 Mulesoft POC 包含 globalErrorHandler 以及具有 OnErrorContinue 范围的 localErrorHandler,我注意到它会引发 MULE:EXPRESSION 错误,谁能告诉我它的原因。下面的代码附在流程图片中。

代码

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
    xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="f8f3f4bb-341a-43ec-acf8-9ed33419f5ef" basePath="/error" >
        <http:listener-connection host="0.0.0.0" port="8082" />
    </http:listener-config>
    <configuration doc:name="Configuration" doc:id="689a9085-287e-43e4-8e3d-5eeac857dc64" defaultErrorHandler-ref="globalError_Handler"/>
    <flow name="example-errorFlow" doc:id="c37abd41-2143-4da1-848a-a8c240853b60" >
        <http:listener doc:name="Listener" doc:id="9cda3f2d-a48d-40bd-96a4-54d856d0438e" config-ref="HTTP_Listener_config" path="/"/>
        <set-payload value='"MAIN"' doc:name="Set Payload" doc:id="a1b3890f-6157-4716-84d3-8f6ccd6e9af5" />
        <ee:transform doc:name="Transform Message" doc:id="9fc2571b-7038-4359-82db-be624d48b343" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
["RESPONSE"] ++ payload ]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <error-handler >
            <on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" type= "HTTP:NOT_FOUND" doc:id="e6f2b028-e3ca-4eff-b878-0f41dd53d693" >
                <set-payload value='"HTTP:NOT_FOUND"' doc:name='"HTTP:NOT_FOUND"' doc:id="c465edf3-bbac-4fca-bfb1-f2a6678e1173" />
            </on-error-continue>
        </error-handler>
    </flow>
    <error-handler name="globalError_Handler" doc:id="05e153b7-d663-4aa1-85c0-8fefbf76c39b" >
        <on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="c0e80820-db0f-4b3f-b0e2-c74c47e3a5e7" >
            <set-payload value="global Error Handler" doc:name="global Error Handler" doc:id="0055b184-4dd6-4d20-8284-27534570f723" />
        </on-error-continue>
    </error-handler>
</mule>

流动图像

【问题讨论】:

  • 您需要添加完整的错误消息,以便我们了解问题。

标签: mule mule-studio mule-component mulesoft mule-esb


【解决方案1】:

错误来自您的 Transform 组件,但您只处理 HTTP:NOT FOUND 错误。

按照此处所述处理所有异常

https://simpleflatservice.com/mule4/OnErrorContinue.html

特别是 - 简单的删除错误类型,您将看到实际消息并可以修复它。 在这里发布,我们可以提供帮助。

【讨论】:

  • 是的,但我想了解是否存在任何错误层次结构,因为 MULE:EXPRESSION 不会被捕获,它只会查找 HTTP:NOT FOUND 错误?
【解决方案2】:

在转换中,您尝试将 ++ 函数与不正确的数组和字符串一起使用(在您的情况下为 ["RESPONSE"] ++ payload 其中payload = "MAIN"),进入流程错误处理您正在处理来自的特定错误HTTP 命名空间,而您得到的错误来自 MULE 类型为 EXPRESSION 的命名空间,这就是本地错误处理程序无法处理该错误的原因。

要处理此问题,请使用 MULE:EXPRESSIONMULE:ANY,它们可以作为 MULE:EXPRSSIONHTTP:NOT_FOUND 错误的父错误类型

MULE 命名空间是一个隐式命名空间,您也可以将其称为父命名空间,它可以处理任何基于运行时的错误。

为了更好地理解错误,它们的层次结构和全局错误处理程序考虑访问下面提到的资源。

https://youtu.be/9WcG9teCrvo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-16
    • 2023-03-09
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多