在WSO2 EI 6.2中捕获端点超时

在WSO2 EI 6.2中捕获端点超时,wso2,wso2esb,wso2ei,Wso2,Wso2esb,Wso2ei,我在EI6.2中有一个调用后端端点的API。有时此EP处于脱机状态,因此呼叫超时。我想捕获此超时,并在将其发送回客户端之前将其封装在自定义响应中。这个想法似乎很简单,但我很难实现它。 我已经尝试在EP声明中添加以下部分。据我所知,action=fault属性应该使EP在请求超时时引发一个错误(因此被错误处理程序序列捕获),但这并没有发生。有人对如何处理这种情况有什么建议吗 谢谢 佩德罗 我的EP: <?xml version="1.0" encoding="UTF-8"?> <

我在EI6.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>

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

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


[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
<?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>