1
我實現了一個代理服務緩存從後端(REST)的Web服務的響應。我對EP的響應做了一些處理,比如將ContentType更改爲application/xml,所以我定義了一個「OnCacheHit」序列,最後我使用send mediator將消息發送回客戶端。但客戶端收到一個空的響應(無論我是直接從我的瀏覽器還是從另一個代理服務中調用該服務)。WSO2 ESB緩存中保緩存是好的,但空響應發送回客戶端
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="PS_with_cache"
transports="https http local" startOnLoad="true" trace="disable"><description />
<target>
<inSequence>
<log level="full" category="DEBUG" xmlns="http://ws.apache.org/ns/synapse" />
<cache id="someCache" scope="per-host" collector="false"
hashGenerator="org.wso2.caching.digest.DOMHASHGenerator" timeout="10">
<onCacheHit>
<property name="ContentType" value="application/xml"
scope="axis2" type="STRING" />
<!-- I have to remove the To header, else it points towards PS_with_cache itself,
generating a "Malformed destination EPR" exception -->
<header name='To' action="remove"/>
<!-- logging the full payload of the message shows that
the cache returned whzat i expected -->
<log category="DEBUG" level="full" />
<send/>
</onCacheHit>
<implementation type="memory" maxSize="1000" />
</cache>
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING" />
<send>
<endpoint key="Back_end_rest_endpoint" />
</send>
</inSequence>
<outSequence>
<property name="ContentType" value="application/xml" scope="axis2"
type="STRING" />
<cache id="someCache" scope="per-host" collector="true" />
<send />
</outSequence>
</target>
</proxy>
只要響應不在緩存中,它就可以完美工作。 onCacheHit序列內的完整日誌顯示緩存返回預期的響應。所以問題在於隨後的「發送」。
我的猜測是,該消息被不恰當地視爲一個請求,而不是響應,所以我試圖改變synapse.isresponse屬性,但它什麼也沒有改變。
我實在想不出這裏發生了什麼,謝謝回答...
嗨,歡迎來到SO,感謝您的回答。請注意,當你提供的鏈接可以爲OP回答網站鏈接的這個問題提供必要的信息是在如此器重。請看http://stackoverflow.com/help/how-to-answer但不要氣餒,所提供的信息可能會幫助OP – Deepend