1

I implemented a proxy service to cache the response from a back-end (rest) web-service. I have some treatments to do on the response of the EP, such as changing ContentType to application/xml, so I defined a "OnCacheHit" sequence, at the end of which I use send mediator to send the message back to the client. But the client receives an empty response (whether I call the service directly from my browser or from another Proxy Service).

<?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>

It works perfectly as long as the response is not in cache. A full log inside the onCacheHit sequence shows that the cache returns the expected response. So the problem lies in the subsequent "send".

My guess was that the message was treated inappropriately as a request rather than a response, so i tried to change the synapse.isresponse property but it changed nothing.

I really can't figure out what's happening here, thanks for answering...

Community
  • 1
  • 1
Hugo
  • 11
  • 1

1 Answers1

0

What is the ESB version that you use and is this tenant specific?

This has been identified in ESB 4.8.0. You can find the fix attached to [1] However response caching is not supported from ESB 4.9.0 onwards.

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

asanthi
  • 49
  • 3
  • Hi and welcome to SO, and thanks for your answer. Please note that while the link you provided might provide the necessary information for the OP to answer this question of site links are discouraged on SO. please take a look at http://stackoverflow.com/help/how-to-answer But don't be discouraged, the information provided will likely help the OP – Deepend May 04 '16 at 12:21