【问题标题】:WSO2 ESB Cache mediator : caching is ok, but empty response sent back to the clientWSO2 ESB 缓存中介:缓存没问题,但空响应发送回客户端
【发布时间】:2016-05-04 19:52:16
【问题描述】:

我实现了一个代理服务来缓存来自后端(休息)网络服务的响应。我对 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 属性,但没有任何改变。

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

【问题讨论】:

    标签: wso2 wso2esb synapse


    【解决方案1】:

    您使用的 ESB 版本是什么?此租户是否特定于该租户?

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

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

    【讨论】:

    • 您好,欢迎来到 SO,感谢您的回答。请注意,虽然您提供的链接可能会为 OP 提供必要的信息来回答此站点链接问题,但在 SO 上不鼓励这样做。请看stackoverflow.com/help/how-to-answer但不要气馁,提供的信息可能会对OP有所帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多