错误 PropagateTransform 消息组件没有覆盖 Mule4 的默认行为。

问题描述 投票:0回答:2

我使用APIKIT Router创建了我的流程。raml main flow+post:/XX flow。主流和我的POSt流都有错误处理组件。

主流。

<flow name="raml-main">
        <http:listener  .....">
            <http:response statusCode="#[vars.httpStatus default 200]">
                <http:body ><![CDATA[ ]]></http:body>
                <http:headers><![CDATA[#[vars.outboundHeaders default {}]]]></http:headers>
            </http:response>
            <http:error-response statusCode="#[vars.httpStatus default 500]">
                <http:body ><![CDATA[#[output application/json --- error.description]]]> 
                     </http:body>
                <http:headers><![CDATA[#[vars.outboundHeaders default {}]]]> 
                            </http:headers>
            </http:error-response>
        </http:listener>

        <apikit:router config-ref="raml-config" />
        <error-handler>
            <on-error-propagate type="APIKIT:BAD_REQUEST">
                <logger level="INFO" doc:name="Logger" doc:id="aa51777e-c1c6-42d2-ba68-b51c45c9aeac" message="Im in MAIN FLOWWWW"/>
                <ee:transform xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd" doc:id="4f00abf2-0b58-419e-8d9a-d3ef60e356ac">
                    <ee:message>
                        <ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{message: "BadMAIN request"}]]></ee:set-payload>
                    </ee:message>
                    <ee:variables>
                        <ee:set-variable variableName="httpStatus"><![CDATA[400]]></ee:set-variable>
                    </ee:variables>
                </ee:transform>
            </on-error-propagate>

后期流量

<flow name="post:\notifications:raml-config">
        <json:validate-schema doc:name="Validate schema" doc:id="e447c719-60e2-4f34-aeb9-0b446a1a5eda" schema="schemas/event.json"/>
        <choice>
.............................
        </choice>
        <error-handler >
              <on-error-propagate type="JSON:SCHEMA_NOT_HONOURED" enableNotifications="true" logException="true">
                <logger level="INFO" doc:name="Logger" doc:id="c818b292-5d89-48eb-aa8d-b7918daa8f0c" message="It is under post flow"/>
                <ee:transform xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd" doc:id="e8fb927d-edb8-405a-b853-600b4788b719">
                    <ee:message>
                        <ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{message: "Bad Request"}]]></ee:set-payload>
                    </ee:message>
                    <ee:variables>
                        <ee:set-variable variableName="httpStatus"><![CDATA[400]]></ee:set-variable>
                    </ee:variables>
                </ee:transform>
            </on-error-propagate>

        </error-handler>
    </flow>

如果我在POST流或RAML主流下更新Transform处理器下的payload,它从来没有反映在输出中。比如目前我收到400个坏的请求。

在Transform组件中,如果我改变了消息,就得不到我修改后的消息。

为什么会这样?

<ee:message>

<ee:set-payload><![CDATA[%dw 2.0

output application/json

---

{message: "Bad Request USER ERRROR.."}]]></ee:set-payload>

</ee:message>

RAML CONFIG

/notifications:
  post:
    headers:
      Authorization:
        required: false
        type: string          

    responses:
      '200':
        description: OK
      '400':
        description: BAD REQUEST
      '401':
        description: NOT AUTHORIZED
mule mule-studio mulesoft mule-esb
2个回答
0
投票

400意味着没有这样的终点。这意味着你的流永远不会被调用。有另一个Mule正在监听的端点。幸运的是,Mule报告了url是错误的,以及它正在监听什么样的url。像这样

INFO  2020-05-07 07:32:22,539 [http.listener.06 SelectorRunner] org.mule.service.http.impl.service.util.DefaultRequestMatcherRegistry: No listener found for request: (GET)/badurl
INFO  2020-05-07 07:32:22,539 [http.listener.06 SelectorRunner] org.mule.service.http.impl.service.util.DefaultRequestMatcherRegistry: Available listeners are: [([*])/console/*, ([*])/, ([*])/api/*]

当然,如果你打到了另一个服务器或另一个端口或协议,那么什么都不知道这个请求。但是,既然你有了答案--400,那么你可能撞到了你的服务器。

https:/simpleflatservice.commule4Recognize400Error.html。

默认的错误处理程序和响应也可以在响应-错误响应部分的http监听器中进行设置

enter image description here


0
投票

HTTP响应400坏请求意味着HTTP请求不符合预期的格式。有可能是APIKit正在根据RAML验证请求。在这种情况下,APIKit将引发错误,并且它将不会执行 post:\notifications:raml-config 流程。你是否已经确认了流程的执行,例如用记录仪?

© www.soinside.com 2019 - 2024. All rights reserved.