【问题标题】:capturing endpoint timeout in WSO2 EI 6.2在 WSO2 EI 6.2 中捕获端点超时
【发布时间】:2020-03-12 01:37:52
【问题描述】:

我在 EI 6.2 中有一个调用后端端点的 API。有时此 EP 离线,因此呼叫超时。我想捕获此超时并将其封装在自定义响应中,然后再将其发送回客户端。这个想法似乎很简单,但我很难实现它。 我尝试将以下部分添加到 EP 声明中。据我了解, action=fault 属性应该使 EP 在请求超时时引发故障(因此被故障处理程序序列捕获),但这并没有发生。有人对如何处理这种情况有任何建议吗?

谢谢。

佩德罗

我的 EP:

<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="wacs_parameters.endpoint" xmlns="http://ws.apache.org/ns/synapse">
    <loadbalance algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
        <endpoint name="WACS_CpeGm_Parameters_Master">
            <http method="GET" uri-template="http://xpto
                <suspendOnFailure>
                    <initialDuration>-1</initialDuration>
                    <progressionFactor>1.0</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                    <retriesBeforeSuspension>0</retriesBeforeSuspension>
                </markForSuspension>
                <timeout>
                    <duration>3000</duration>
                    <action>fault</action>
                </timeout>
            </http>
        </endpoint>
    </loadbalance>
    <description/>
</endpoint>

这是请求中的日志,为清楚起见进行了编辑:

[2020-02-26 16:38:33,962] [EI-Core]  WARN - TimeoutHandler Expiring message ID : urn:uuid:8b9c9632-ef0b-423d-9827-84eee517b75d; dropping message after ENDPOINT_TIMEOUT of : 3 seconds for Endpoint [WACS_CpeGm_Parameters_Master], URI : xpto, Received through API : ClientEquipmentsAPI
[2020-02-26 16:38:41,318] [EI-Core]  WARN - ConnectCallback Connection refused or failed for : /10.217.49.10:8280
[2020-02-26 16:38:41,318] [EI-Core]  WARN - SynapseCallbackReceiver Synapse received a response for the request with message Id : urn:uuid:8b9c9632-ef0b-423d-9827-84eee517b75d But a callback is not registered (anymore) to process this response
[2020-02-26 16:40:33,967] [EI-Core]  WARN - TimeoutHandler Expiring message ID : urn:uuid:2a928d56-cf7f-4950-a5f4-8033798e205e; dropping message after GLOBAL_TIMEOUT of : 120 seconds for Endpoint [API_ClientEquipments_Endpoint_Master], URI : xpto, Received through API : ClientEquipmentsAPI
[2020-02-26 16:41:20,394] [EI-Core]  INFO - SourceHandler Writer null when calling informWriterError
[2020-02-26 16:41:20,394] [EI-Core]  WARN - SourceHandler Connection time out after request is read: http-incoming-10 Socket Timeout : 180000 Remote Address : /127.0.0.1:53092
[2020-02-26 16:41:20,408] [EI-Core]  INFO - SourceHandler Writer null when calling informWriterError
[2020-02-26 16:41:20,408] [EI-Core]  WARN - TargetHandler Connection time out after while in state : REQUEST_DONE Socket Timeout : 180000 Remote Address : localhost/127.0.0.1:8280
[2020-02-26 16:41:20,408] [EI-Core]  WARN - SourceHandler Connection time out after request is read: http-incoming-11 Socket Timeout : 180000 Remote Address : /127.0.0.1:53093
[2020-02-26 16:41:20,409] [EI-Core]  WARN - SynapseCallbackReceiver Synapse received a response for the request with message Id : urn:uuid:2a928d56-cf7f-4950-a5f4-8033798e205e But a callback is not registered (anymore) to process this response

【问题讨论】:

    标签: wso2 wso2esb wso2ei


    【解决方案1】:

    所以,只是为了通知可能有同样问题的其他人:当端点超时时,EI 会激活故障序列。在那里,您可以发现故障并正确处理。属性 ERROR_MESSAGE 详细说明了错误的类型,如此处所述

    https://docs.wso2.com/display/EI640/Error+Handling

    此示例序列捕获超时并返回自定义错误代码(使用 HTTP 502):

    <?xml version="1.0" encoding="UTF-8"?>
    <sequence name="faultSequence_ClientEquipmentsAPI" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
        <switch source="get-property('ERROR_CODE')">
            <case regex="101503|101504">
                <call-template target="faultTemplate_clientEquipmentsAPI">
                    <with-param name="res_messageCode" value="801"/>
                    <with-param name="res_message" value="Timeout waiting answer of backend system"/>
                </call-template>
                <property name="HTTP_SC" scope="axis2" type="STRING" value="502"/>
                <respond/>
            </case>
       </switch>
    </sequence>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多