有人可以向我解释如何启用正确的重试吗?我仅使用从WSO2站点下载的Integration Studio编辑器。
我有带有URL https://api.github.com/user
的代码,该代码返回401和JSON(请参阅日志)。那么,为什么WSO2等待configuratipon文件中设置的超时(我将其更改为30秒)?在获得[401]或<timeout><duration>
中的时间后,是否应该立即重试?
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="HelloWorld" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>
<property name="NO_KEEPALIVE" scope="axis2" type="STRING" value="true"/>
<send>
<endpoint name="github">
<address format="get" optimize="mtom" uri="https://api.github.com/user">
<timeout>
<duration>5</duration>
<responseAction>fault</responseAction>
</timeout>
<suspendOnFailure>
<initialDuration>1000</initialDuration>
<progressionFactor>2.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>3</retriesBeforeSuspension>
<retryDelay>1000</retryDelay>
</markForSuspension>
</address>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<log level="custom">
<property expression="$axis2:HTTP_SC" name="###### HTTP Status #######" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<respond/>
</outSequence>
<faultSequence/>
</target>
</proxy>
WSO2日志:
[2020-06-14 14:51:57,811] INFO {org.apache.synapse.transport.passthru.SourceHandler} - Writer null when calling informWriterError
[2020-06-14 14:51:57,812] WARN {org.apache.synapse.transport.passthru.SourceHandler} - Connection time out after request is read: http-incoming-4 Socket Timeout : 30000 Remote Address : /127.0.0.1:55124
[2020-06-14 14:51:58,149] INFO {org.apache.synapse.endpoints.EndpointContext} - Endpoint : github with address https://api.github.com/user currently TIMEOUT will now be marked active since it processed its last message
[2020-06-14 14:51:58,150] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:76137204-8644-4e3c-a1ba-4e1f011382ea, Direction: response, Payload: {"message":"Requires authentication","documentation_url":"https://developer.github.com/v3/users/#get-the-authenticated-user"}
[2020-06-14 14:51:58,151] INFO {org.apache.synapse.mediators.builtin.LogMediator} - ###### HTTP Status ####### = 401
[2020-06-14 14:52:27,843] INFO {org.apache.synapse.transport.passthru.SourceHandler} - Writer null when calling informWriterError
[2020-06-14 14:52:27,844] WARN {org.apache.synapse.transport.passthru.SourceHandler} - Connection time out after request is read: http-incoming-5 Socket Timeout : 30000 Remote Address : /127.0.0.1:55145
[2020-06-14 14:52:28,341] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:35dda6ba-faae-47bd-8180-d130a1604877, Direction: response, Payload: {"message":"Requires authentication","documentation_url":"https://developer.github.com/v3/users/#get-the-authenticated-user"}
[2020-06-14 14:52:28,343] INFO {org.apache.synapse.mediators.builtin.LogMediator} - ###### HTTP Status ####### = 401
[2020-06-14 14:52:57,868] INFO {org.apache.synapse.transport.passthru.SourceHandler} - Writer null when calling informWriterError
[2020-06-14 14:52:57,869] WARN {org.apache.synapse.transport.passthru.SourceHandler} - Connection time out after request is read: http-incoming-6 Socket Timeout : 30000 Remote Address : /127.0.0.1:55164
如何使其运作?
您能否像下面那样使用地址端点代替http。
<endpoint>
<address uri="http://localhost:8000">
<suspendOnFailure>
<initialDuration>1000</initialDuration>
<progressionFactor>2.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>3</retriesBeforeSuspension>
<retryDelay>1000</retryDelay>
</markForSuspension>
<timeout>
<duration>6000</duration>
<responseAction>fault</responseAction>
</timeout>
</address></endpoint>