1

我实现了一个代理服务来缓存来自后端(休息)Web 服务的响应。我对 EP 的响应做了一些处理,比如将 ContentType 更改为 application/xml,所以我定义了一个“OnCacheHit”序列,最后我使用 send mediator 将消息发送回客户端。但是客户端收到一个空响应(无论我是直接从浏览器还是从另一个代理服务调用服务)。

<?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 属性,但它没有任何改变。

我真的不知道这里发生了什么,谢谢你的回答......

4

1 回答 1

0

您使用的 ESB 版本是什么?这个租户是特定的吗?

这已在 ESB 4.8.0 中确定。您可以找到附加到 [1] 的修复程序,但是从 ESB 4.9.0 开始不支持响应缓存。

[1] https://wso2.org/jira/browse/ESBJAVA-3665

于 2016-05-04T11:52:16.403 回答