我們正在使用最新版本的WSO2 ESB(4.6.0)。我們正在探索如何將代理服務實現爲Web服務。詳細信息如下:WSO2 ESB服務代理不按照配置超時
使用WSO2設置Axis2 Webservice自定義服務代理。配置如下: 代理XML:此突觸配置是使用WSO2 UI生成的。
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="https,http" statistics="enable" trace="enable" startOnLoad="true">
<target faultSequence="myFaultHandler">
<inSequence>
<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService">
<timeout>
<duration>3000</duration>
<responseAction>fault</responseAction>
</timeout>
<suspendOnFailure>
<errorCodes>101504,101505</errorCodes>
<initialDuration>1000</initialDuration>
<progressionFactor>2.0</progressionFactor>
<maximumDuration>10000</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<errorCodes>101507,101508,101505,101506,101509,101500,101510,101001,101000,101503,101504,101501</errorCodes>
<retriesBeforeSuspension>1</retriesBeforeSuspension>
<retryDelay>1</retryDelay>
</markForSuspension>
</address>
</endpoint>
</target>
<publishWSDL uri="http:// localhost:9000/services/SimpleStockQuoteService?wsdl"/>
<description></description>
</proxy>
序列myFaultHandler XML:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="myFaultHandler" trace="enable">
<header name="To" action="remove"/>
<property name="RESPONSE" value="true"/>
<property name="NO_ENTITY_BODY" action="remove" scope="axis2"/>
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="error-message" expression="get-property('ERROR_MESSAGE')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="error-code" expression="get-property('ERROR_CODE')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="error-detail" expression="get-property('ERROR_DETAIL')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="error-exception" expression="get-property('ERROR_EXCEPTION')"/>
</log>
<makefault version="soap12">
<code xmlns:soap12Env="http://www.w3.org/2003/05/soap-envelope" value="soap12Env:Receiver"/>
<reason value="Webservice is either down or currently not reachable."/>
<node></node>
<role></role>
</makefault>
<send/>
</sequence>
當web服務是向下,該配置拋出所定義的皁故障。
當web服務需要時間來響應中發回,如在代理XML配置中定義的3秒後它應該超時:
即使在超時時段之後 <timeout>
<duration>3000</duration>
<responseAction>fault</responseAction>
</timeout>
代理仍在等待響應而不是把錯誤拋回去。
在分析日誌文件時,我們嘗試通過修改下面提到的屬性文件中的以下參數,但是線程仍然等待響應。
**synapse.properties**
synapse.global_timeout_interval=3000
synapse.connection.read_timeout=3000
synapse.connection.connect_timeout=3000
synapse.timeout_handler_interval=3000
**nhttp.properties**
http.socket.timeout=5000
它最終超時並拋出套接字異常。
根據規範(http://wso2.com/library/articles/wso2-enterprise-service-bus-endpoint-error-handling)在超時發生後,端點應該進入超時狀態,但在這種情況下端點仍處於活動狀態,它既不是錯誤也不是丟棄消息。有時它會拋出一個錯誤代碼504.但是這種行爲並不一致。
如果最終的web服務非常慢,請讓我們知道給定代理服務所需的更改以超時/丟棄消息。